2013-07-18 39 views
0

我在与哈特尔的回报率教程第5章练习1.哈特尔回报率教程第5章练习1:失败的测试:it_should_behave_like和should_not have_title

的行使设置了测试规范的问题。在下面的测试规范中给出。

当我运行“bundle exec rspec spec/”时,出现ERROR下面给出的错误。

如果我注释掉两个:

it_should_behave_like "all static pages" 
it { should_not have_title('| Home') } 

测试通过...

问:这有什么错it_should_behave_likeshould_not have_title

**ERROR** 

o DRb server is running. Running in local process instead ... 
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8 
F...F...... 

Failures: 

    1) Static pages Home page 
    Failure/Error: it { should_not have_title('| Home') } 
    NoMethodError: 
     undefined method `has_title?' for #<Capybara::Session> 
    # ./spec/requests/static_pages_spec.rb:18:in `block (3 levels) in <top (required)>' 

**TEST SPEC** 



require 'spec_helper' 

describe "Static pages" do 

    subject { page } 

    shared_examples_for "all static pages" do 
    it { should have_content(heading) } 
    it { should have_title(full_title(page_title)) } 
    end 

    describe "Home page" do 
    before { visit root_path } 
    let(:heading) { 'Sample App' } 
    let(:page_title) { '' } 

    it_should_behave_like "all static pages" 
    it { should_not have_title('| Home') } 
    end 

....... 
....... 
....... 

回答

相关问题