RoR 3.1:使用 rspec 测试正确的标题
require 'spec_helper'
describe "LayoutLinks" do
it "should have a Home page at '/'" do
get '/'
response.should have_selector('title', :content => "Home")
end
end
规范来源: https://github.com/railstutorial/sample_app/ blob/master/spec/requests/layout_links_spec.rb (我正在读这本书)
我尝试放置integrate_views和render_views,但它返回了未定义的变量错误。
$ guard
Guard is now watching at '[project dir]'
Guard::RSpec is running, with RSpec 2!
Running all specs
F
Failures:
1) LayoutLinks should have a Home page at '/'
Failure/Error: response.should have_selector('title', :content => "Home")
expected css "title" to return something
# ./spec/requests/layout_links_spec.rb:5:in `block (2 levels) in <top (required)>'
Finished in 13.15 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/requests/layout_links_spec.rb:3 # LayoutLinks should have a Home page at '/'
我的 Gemfile 的一部分:
gem 'rails', '3.1.0'
group :development, :test do
gem 'turn', :require => false
gem 'sqlite3'
gem "rspec-rails"
gem "factory_girl_rails"
gem "capybara"
gem "guard-rspec"
end
用于设置我遵循的所有内容: http://railscasts.com/episodes/275-how-i-test ?view=asciicast
我的根目录的一部分:有标题标签并位于“站点名称 | 主页”内
require 'spec_helper'
describe "LayoutLinks" do
it "should have a Home page at '/'" do
get '/'
response.should have_selector('title', :content => "Home")
end
end
Spec source: https://github.com/railstutorial/sample_app/blob/master/spec/requests/layout_links_spec.rb
(I'm reading the book)
I tried putting integrate_views and render_views, but it returned an undefined variable error.
$ guard
Guard is now watching at '[project dir]'
Guard::RSpec is running, with RSpec 2!
Running all specs
F
Failures:
1) LayoutLinks should have a Home page at '/'
Failure/Error: response.should have_selector('title', :content => "Home")
expected css "title" to return something
# ./spec/requests/layout_links_spec.rb:5:in `block (2 levels) in <top (required)>'
Finished in 13.15 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/requests/layout_links_spec.rb:3 # LayoutLinks should have a Home page at '/'
Part of my Gemfile:
gem 'rails', '3.1.0'
group :development, :test do
gem 'turn', :require => false
gem 'sqlite3'
gem "rspec-rails"
gem "factory_girl_rails"
gem "capybara"
gem "guard-rspec"
end
For setting up everything I followed:
http://railscasts.com/episodes/275-how-i-test?view=asciicast
Part of my root directory: Has the title tag and inside "Name of Site | Home"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
Try this: