4

我正在使用 Cucumber 和 Capybara/rack_test 测试 rails 应用程序。我有以下步骤定义:

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

about_path映射到哪里/about

每次我的故事都因信息而失败

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)

请注意,实际内容为空。我尝试过的每条路径都是空的。

这很奇怪,因为 rspecs 通过了。

有什么我可以尝试的吗?如果您需要更多信息,请告诉我。

4

1 回答 1

0

您不应该使用response来获取内容。尝试使用page

于 2012-12-11T14:53:31.530 回答