Я установил новое приложение Rails 3.1 с некоторыми гемами:
source 'http://rubygems.org'
gem 'rails', '3.1.1'
gem 'sqlite3', '1.3.4'
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'unicorn', '4.1.1'
gem execjs, 1.2.9
gem therubyracer, '0.9.9'
gem 'gravatar_image_tag', '1.0.0'
group :test do
# Pretty printed test output
gem 'turn', '0.8.3', :require => true
gem 'rspec-rails', '2.7.0'
gem 'syntax', '1.0.0'
gem 'factory_girl_rails', '1.3.0'
end
group :development do
gem 'webrat', '0.7.3'
gem 'rspec-rails', '2.7.0'
gem 'syntax', '1.0.0'
end
group :production do
end
$ bundle exec rails new calculator -T
$ cd calculator
$ bundle exec rails g rspec:install
Создать файл
require 'spec_helper'
describe PagesController do
render_views
before(:each) do
@base_title = "Calculator Tutorial Application | "
end
describe "GET 'home'" do
it "returns http success" do
get 'home'
response.should be_success
end
it "should have the right title" do
get 'home'
response.should have_selector("title",
:content => @base_title + "Home")
end
end
end
и запустить тест
$ ./bin/rspec spec/controllers/pages_controller_spec.rb
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require': can't convert true into String (TypeError)
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
from /home/ror/calculator/config/application.rb:13:in `'
from /home/ror/calculator/config/environment.rb:2:in `require'
from /home/ror/calculator/config/environment.rb:2:in `'
from /home/ror/calculator/spec/spec_helper.rb:3:in `require'
from /home/ror/calculator/spec/spec_helper.rb:3:in `'
from /home/ror/calculator/spec/controllers/pages_controller_spec.rb:1:in `require'
from /home/ror/calculator/spec/controllers/pages_controller_spec.rb:1:in `'
from /home/ror/.gem/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load'
from /home/ror/.gem/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `block in load_spec_files'
from /home/ror/.gem/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `map'
from /home/ror/.gem/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load_spec_files'
from /home/ror/.gem/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:18:in `run'
from /home/ror/.gem/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:80:in `run_in_process'
from /home/ror/.gem/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:69:in `run'
from /home/ror/.gem/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `block in autorun'
После строки комментария 13 в ./config/application.rb: <code># Bundler.require(*Rails.groups(:assets => %w(development test)))
Тестовая система Rspec работает нормально, но у меня есть другая проблема с gravatar_image_tag, которая работает только для комментария из строки Bundle.requre.
Все гемы устанавливаются поверх связующего в домашнем каталоге пользователя.