1
我已创建一个static_pages_controller.rbRSpec的护栏宝石EXEC
这是我之后,创建一个功能
def home
end
我已创建一个视图home.html.erb 我刚才写这样做“示例应用程序”
之后,我有安装宝石RSpec的护栏,并创建static_pages_spec.rb
require 'spec_helper'
describe "StaticPages" do
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
page.should have content('Sample App')
end
end
end
我已经运行在终端
$ bundle exec rspec spec/requests/static_pages_spec.rb
F
Failures:
1) StaticPages Home page should have the content 'Sample App'
Failure/Error: visit '/static_pages/home'
NoMethodError:
undefined method `visit' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0xa3a7870>
# ./spec/requests/static_pages_spec.rb:5:in `block (3 levels) in <top (required)>'
Finished in 0.00248 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/requests/static_pages_spec.rb:4 # StaticPages Home page should have the content 'Sample App'
Randomized with seed 57243
这个命令什么是错的?与此请请hellp我
不明白这一点:( – Harman
重命名'规格/请求/ static_pages_spec.rb'是'spec/features/static_pages_spec.rb'(即把它放在features子目录中而不是请求),它应该可以工作。 –
现在我的目录stu就像这样“spec/features/static_pages_spec.rb”,我运行这个命令“ $ bundle exec rspec spec/feat ures/static_pages_spec.rb“无法正常工作 – Harman