简体   繁体   English

与Capybara黄瓜只获得空白页

[英]Cucumber with Capybara gets blank pages only

I'm testing rails app with the Cucumber and Capybara/rack_test. 我正在使用Cucumber和Capybara / rack_test测试rails应用程序。 I have following step definition: 我有以下步骤定义:

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

where about_path maps to /about . 其中about_path映射到/about

Every time my story fails with the 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)

Note that actual content is empty. 请注意,实际内容为空。 It is empty with every path I've tried. 我试过的每一条路都是空的。

It is strange because rspecs passes. 这很奇怪,因为rspecs通过了。

Is there anything I could try? 有什么我可以尝试的吗? Tell me if you need additional information. 如果您需要其他信息,请告诉我。

You shouldn't use response to get to the content. 您不应该使用response来获取内容。 Try with page instead. 请尝试使用page

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM