我正在使用导轨。我使用以下命令执行 ruby 脚本。它给出了一个错误。会有什么问题?如果我删除“page.should have_content('Demo App')”,那么它可以正常工作!
bundle exec rspec spec/requests/test_pages_spec.rb
Failures:
1) Test pages Home page should have the content 'Demo App'
Failure/Error: page.should have_content('Demo App')
NameError:
undefined local variable or method `page' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0xa60d538>
# ./spec/requests/test_pages_spec.rb:9:in `block (3 levels) in <top (required)>'
Finished in 0.27788 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/requests/test_pages_spec.rb:7 # Test pages Home page should have the content 'Demo App'
test_pages_spec.rb 如下:
require 'spec_helper'
describe "Test pages" do
describe "Home page" do
it "should have the content 'Demo App'" do
visit '/test_pages/home'
page.should have_content('Demo App')
end
end
end