Capybara cucumber only gets blank pages

I am testing a rails application with Cucumber and Capybara / rack_test. I have the following step definition:

Then /^I should see '([^']*)'$/ do |content| visit about_path response.should have_content(content) end 

where about_path maps to /about .

Every time my story crashes with a message

 Feature: Some Great Feature So that I can blah-blah As a Blah-blah I want blah-blah Scenario: Show project label on about page # features/about.feature:7 Given I'm on '/about' page # features/step_definitions/about_steps.rb:1 Then I should see 'About' # features/step_definitions/about_steps.rb:5 expected there to be content "About" in "" (RSpec::Expectations::ExpectationNotMetError) ./features/step_definitions/about_steps.rb:7:in `/^I should see '([^']*)'$/' features/about.feature:9:in `Then I should see 'About'' Failing Scenarios: cucumber features/about.feature:7 # Scenario: Show project label on about page 1 scenario (1 failed) 2 steps (1 failed, 1 passed) 

Please note that the actual content is empty. It is empty for every path I tried.

This is strange because rspecs goes through.

Is there anything I could try? Tell me if you need more information.

+4
source share
1 answer

You should not use response to access content. Use page instead.

0
source

Source: https://habr.com/ru/post/1439839/


All Articles