2013-10-07 30 views
0

你好,我遇到了railstutorial的问题。rspec:未定义方法'has_conent?'

我有测试文件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.rbconfig.include Capybara::DSL增加,但它给了我同样的错误。

+0

感谢我没有看到这个愚蠢的错误 –

+0

它发生:)如果它帮助,请检查答案所以它出来的“悬而未决”队列 – dax

回答

5

只是一个错字:

page.should have_conent('Sample App') 

应该

page.should have_content('Sample App') 
1

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

page.should have_content('Sample App') 
相关问题