Capybara::Remote::Viewer
Capybara remote viewer runs a server that provides a navigable browser interface
to the HTML dumps generated by capybara's save_page
helper. It is especially
useful if you're developing an app on a remote machine or working within a shell
that can't open a browser window on your desktop.
Installation
Add this line to your application's Gemfile:
gem 'capybara-remote-viewer'
And then execute:
$ bundle
Or install it yourself as:
$ gem install capybara-remote-viewer
Usage
As a stand-alone binary
Start a server with: $ capy-remote
It will start on port 3000 by default and look in the current working directory (and all subdirectories) for any .html files to serve.
You can specify a path to a directory containing .html files with the -t option.
You can also specify the port with the -p option.
With foreman
Add a binstub
$ bundle binstub capybara-remote-viewer
Add a line to your Procfile
capy: bin/capy-remote -t tmp -p $PORT
Interface
All files dumped by capybara with the save_page
method will automatically
appear in the viewer interface as they are generated. No need to refresh!
Optional capybara configuration
Capybara does not clean up after itself when it dumps html files, so as these files appear, they will fill up remote viewer's interface with old junk. You can tell cucumber to clean these up before each run.
In features/support/capybara.rb:
AfterConfiguration do |config|
Dir.glob(File.expand_path('../../../tmp/capybara/*', __FILE__)).
each { |f| FileUtils.rm_f f }
end
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request