0

您好,我在使用 railstutorial 时遇到问题。

我有测试文件features/static_pages_spec.rb

require 'spec_helper'

describe "Static pages" do
  describe "Home page" do
    it "Should have the content 'Sample App'" do
      visit '/static_pages/home'
      page.should have_conent('Sample App')
    end
  end
end

当我跑步时bundle exec rspec spec/features/static_pages_spec.rb

我收到以下错误:

Failures:

  1) Static pages Home page Should have the content 'Sample App'
     Failure/Error: page.should have_conent('Sample App')
     NoMethodError:
       undefined method `has_conent?' for #<Capybara::Session>
     # ./spec/features/static_pages_spec.rb:9:in `block (3 levels) in <top (required)>'

Finished in 0.05262 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/features/static_pages_spec.rb:6 # Static pages Home page Should have the content 'Sample App'

Randomized with seed 49777

我试图添加,spec_helper.rb config.include Capybara::DSL但它给了我同样的错误。

4

2 回答 2

5

只是一个错字:

page.should have_conent('Sample App')

应该

page.should have_content('Sample App')
于 2013-10-07T13:48:44.450 回答
1

有一个错字。t您的内容中缺少 a

page.should have_content('Sample App')
于 2013-10-07T13:48:56.460 回答