Skip to content

Add Capybara-screenshot #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ group :test do
gem 'shoulda-matchers', '3.0.0.rc1'
gem 'vcr'
gem 'webmock'
gem 'capybara-screenshot'
end
6 changes: 5 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
capybara-screenshot (1.0.11)
capybara (>= 1.0, < 3)
launchy
childprocess (0.5.6)
ffi (~> 1.0, >= 1.0.11)
cliver (0.3.2)
Expand Down Expand Up @@ -260,6 +263,7 @@ PLATFORMS
DEPENDENCIES
byebug
capybara
capybara-screenshot
coffee-rails (~> 4.1.0)
database_cleaner
devise
Expand Down Expand Up @@ -289,4 +293,4 @@ DEPENDENCIES
webmock

BUNDLED WITH
1.10.5
1.10.6
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ VCR configuration how-to and examples:

[Capybara](https://github.com/jnicklas/capybara) helps you write feature specs that interact with your app's UI as a user does with a browser.

[Capybara Screenshot](https://github.com/mattheworiordan/capybara-screenshot) will automatically save screen shots when a Capybara scenario fails.

Capybara configuration how-to and examples:
- [spec/support/capybara.rb](spec/support/capybara.rb)
- [spec/support/capybara_screenshot.rb](spec/support/capybara_screenshot.rb)
- [spec/features/home_page_spec.rb](spec/features/home_page_spec.rb)
- [spec/features/subscribe_to_newsletter_spec.rb](spec/features/subscribe_to_newsletter_spec.rb)
- [spec/features/user_login_and_logout_spec.rb](spec/features/user_login_and_logout_spec.rb)
Expand Down
46 changes: 46 additions & 0 deletions spec/support/capybara_screenshot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Installing capybara-screenshot:

# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Add capybara-screenshot to Gemfile:
#
# group :test do
# gem 'capybara-screenshot'
# end
#
# 2. Create a file like this one you're reading in spec/support/capybara-screenshot.rb:

require 'capybara-screenshot/rspec'

# Manual screenshot.
# This is useful if the failure occurs at a point where the
# screen shot is not as useful for debugging a rendering problem.

# Anywhere the Capybara DSL methods (visit, click etc.) are available so
# too are the screenshot methods. Defaults is true
# Capybara::Screenshot.autosave_on_failure = false

# Specify a custom screenshot size. Default is 1000px
# Capybara::Screenshot.webkit_options = { width: 1024, height: 768 }

# Custom screenshot file name for a specific test library.
# Capybara::Screenshot.register_filename_prefix_formatter(:rspec) do |example|
# "screenshot_#{example.description.gsub(' ', '-').gsub(/^.*\/spec\//,'')}"
# end

# Disable time stamp in the basename. Defaults is true
# Capybara::Screenshot.append_timestamp = false

# Custom screenshot directory. Defaults is `$APPLICATION_ROOT/tmp/capybara`
# Capybara.save_and_open_page_path = "/your/file/path"

# Pruning old screenshot automatically. Defaults screenshots are saved indefinitely
#
# Keep only the screenshots generated from the last failing test suite
# Capybara::Screenshot.prune_strategy = :keep_last_run
#
# Keep up to the number of screenshots specified in the hash
# Capybara::Screenshot.prune_strategy = { keep: 10 }

# Disable the screenshots information for each failed spec. Defautls is enable
# Capybara::Screenshot::RSpec.add_link_to_screenshot_for_failed_examples = false