rspec:未定义的方法'has_conent?'

ƒer*_*lle 0 ruby rspec ruby-on-rails capybara

您好我遇到了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
Run Code Online (Sandbox Code Playgroud)

我跑的时候 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
Run Code Online (Sandbox Code Playgroud)

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

dax*_*dax 5

只是一个错字:

page.should have_conent('Sample App')
Run Code Online (Sandbox Code Playgroud)

应该

page.should have_content('Sample App')
Run Code Online (Sandbox Code Playgroud)