我是 ruby 新手,我刚刚开始我的第一个项目。当我试图通过 rspec 运行我的第一个测试时,我失败了。
这是我的宝石文件:
source 'https://rubygems.org'
gem 'rails', '3.2.12'
gem 'bootstrap-sass', '2.3.0.1'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.1.2'
gem 'will_paginate', '3.0.4'
gem 'bootstrap-will_paginate', '0.0.9'
gem 'jquery-rails', '2.2.1'
gem 'mysql2'
#gem 'execjs'
gem 'therubyracer', :platforms => :ruby
# Dev and test gems
group :development, :test do
gem 'rspec-rails', '2.13.0'
gem 'guard-rspec', '2.4.1'
gem 'guard-spork', '1.4.2'
gem 'spork', '0.9.2'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.6'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.3.0'
end
#only test gems
group :test do
gem 'capybara', '2.0.2'
gem 'factory_girl_rails', '4.2.1'
gem 'cucumber-rails', '1.3.0', :require => false
gem 'database_cleaner', '0.9.1'
# gem 'launchy', '2.1.0'
# gem 'rb-fsevent', '0.9.1', :require => false
# gem 'growl', '1.0.3'
end
group :production do
gem 'pg', '0.12.2'
end
这是我的 home_pages_spec.rb
require 'spec_helper'
describe "HomePages" do
before { get 'home_page/home'}
it { should have_content("Home")}
end
当我跑步时
bundle exec rspec spec/requests/home_pages_spec.rb
我明白了
Failures:
1) HomePages
Failure/Error: it { should have_content("Home")}
NoMethodError:
undefined method `has_content?' for "HomePages":String
# ./spec/requests/home_pages_spec.rb:5:in `block (2 levels) in <top (required)>'
请帮帮我,我搜索了一下,发现了类似的问题,但不是很清楚.. 再加上它们有点旧,现在不是以前的错误了。
另外,如果您能向我解释为什么我不能使用访问命令(对于 RSpec::Core::ExampleGroup::Nested_1...,也是未定义的方法 `visit')并且必须使用 get 命令,那就太好了