0

我在使用 Hartl 的 RoR 教程第 5 章练习 1 时遇到问题。

该练习设置了测试规范。在下面的测试规范中给出。

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

如果我将两者都注释掉:

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

测试通过...

it_should_behave_like问题:和有什么问题should_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

.......
.......
.......
4

1 回答 1

0

尝试在 Gemfile 中将 Capybara 更新到 2.1.0 版本。have_title是新的选择器之一。

查看此答案以获取更多信息

于 2013-07-19T00:43:28.003 回答