I'm using rspec and capybara to do some testing for some form-paths we have, but it's developed in PHP, so just looking for HTML. So in order to get to the next question of the process, I have to answer the previous one question form and click_button to get to the next part. I'm doing this for each. Here's an example of what I'm dealing with:
describe 'Fourth Step' do
before do
visit '/thiseffingwebsite'
select 'someAnswer', from: 'someQuestion'
click_button "Continue"
select 'someAnswer2', from: 'someQuestion2'
click_button "Continue"
select 'someAnswer3', from: 'someQuestion3'
click_button "Continue"
end
it "should have certain content" do
some stuff
end
it "should have stuff on next page after clicking Continue" do
fill out form
click_button 'Continue'
stuff on next page should be present
end
end
And this goes on for 12 steps. I have to put that describe block along with the next step for each test. Any suggestions? I looked into 'let' but couldn't find a way to apply it. Thanks.
If you are only trying to test that the server sends the correct response to a certain set of form values, you can follow the example in this blog post and just post the filled-out form, then check that the returned page has the correct text.
True, this goes against the spirit of Capybara testing, but in your case you don't care how the form works on the page, only that the correct response comes back.