Mike Simmons
Mike Simmons

Reputation: 328

rspec save_and_open_page does create an html dump

I am trying to use save_and_open_page to see the details of why an rspec test is failing:

Related Test Code

it { should have_selector('div.alert'); save_and_open_page} 

the test executes and fails but now output is generated

Related Gemfile snippet:

group :test do
  gem 'capybara', '1.1.2'
  gem 'factory_girl_rails', '4.1.0'
  gem 'launchy'
end

Launchy was installed okay:

$ bundle show launchy
//.rvm/gems/ruby-1.9.3-p286/gems/launchy-2.1.2

Related config/test.rb snippet (I'm expecting the save_and_open_page output to arrive here)

Capybara.save_and_open_page_path = 'tmp/test_out'

Any ideas why the output does not show up?

Upvotes: 2

Views: 1673

Answers (1)

Chris Peters
Chris Peters

Reputation: 18090

Try putting the save_and_open_page before the failing test:

it { save_and_open_page; should have_selector('div.alert') }

Otherwise, once it runs should have_selector('div.alert'), it won't continue on to the save_and_open_page because the test has already failed.

Upvotes: 7

Related Questions