我在使用Hartl的RoR教程第5章练习1时遇到了问题。
练习设定了测试规范。在TEST SPEC中给出。
当我运行“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
.......
.......
.......
答案 0 :(得分:0)
尝试将Capybara更新为Gemfile中的2.1.0版。 have_title
是新选择者之一。