Hello,
I am a complete newbie to both ruby and rspec. I am following the
steps in the railstutorial.org book to learn ruby on rails. The
current step involves setting up rspec for the tests, and this is
where I am stuck. Here’s what I am doing:
$ cat spec/controllers/pages_controller_spec.rb
require ‘spec_helper’
describe PagesController do
describe “GET ‘home’” do
it “should be successful” do
get ‘home’
response.should be_success
end
end
describe “GET ‘contact’” do
it “should be successful” do
get ‘contact’
response.should be_success
end
end
end
$ rake --trace spec
(in /home/daniel/programming/rails_projects/sample_app)
** Invoke spec (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
** Execute spec
./spec/controllers/pages_controller_spec.rb:1:in require': no such file to load -- spec_helper (LoadError) from ./spec/controllers/pages_controller_spec.rb:1 rake aborted! bundle exec /usr/bin/ruby1.8 -Ilib -Ispec "./spec/controllers/ pages_controller_spec.rb" failed /usr/lib/ruby/gems/1.8/gems/rspec-core-2.0.0.beta.19/lib/rspec/core/ rake_task.rb:72 /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1112:in
verbose’
/usr/lib/ruby/gems/1.8/gems/rspec-core-2.0.0.beta.19/lib/rspec/core/
rake_task.rb:65:in send' /usr/lib/ruby/gems/1.8/gems/rspec-core-2.0.0.beta.19/lib/rspec/core/ rake_task.rb:65 /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
call’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in execute' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
each’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in execute' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
invoke_with_call_chain’
/usr/lib/ruby/1.8/monitor.rb:242:in synchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
invoke_with_call_chain’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in invoke' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in
invoke_task’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
each’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
standard_exception_handling’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in
run’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in
run’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load’
/usr/bin/rake:19
So it seems spec_helper is not being found, am I right? A search of my
system (Ubuntu 10.04) shows this file in several places:
$ sudo find / -name spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/rspec-expectations-2.0.0.beta.18/spec/
spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/rspec-mocks-2.0.0.beta.19/spec/
spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/thor-0.14.0/spec/spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/launchy-0.3.7/spec/spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/spec/spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/rspec-expectations-2.0.0.beta.19/spec/
spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/rspec-core-2.0.0.beta.19/spec/
spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/treetop-1.4.8/spec/runtime/
interval_skip_list/spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/treetop-1.4.8/spec/spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/rspec-rails-1.3.2/generators/rspec/
templates/spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/rspec-rails-1.3.2/spec/spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/rspec-core-2.0.0.beta.18/spec/
spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/webrat-0.7.1/spec/spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/webrat-0.7.1/spec/integration/merb/spec/
spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/webrat-0.7.1/spec/integration/mechanize/
spec/spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/arel-0.4.0/spec/spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/rspec-mocks-2.0.0.beta.18/spec/
spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/rack-test-0.5.4/spec/spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/rspec-rails-2.0.0.beta.18/lib/generators/
rspec/install/templates/spec/spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/rspec-rails-2.0.0.beta.18/spec/
spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/rspec-rails-2.0.0.beta.19/lib/generators/
rspec/install/templates/spec/spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/rspec-rails-2.0.0.beta.19/spec/
spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/webrat-0.7.2.beta.1/spec/spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/webrat-0.7.2.beta.1/spec/integration/merb/
spec/spec_helper.rb
/usr/lib/ruby/gems/1.8/gems/webrat-0.7.2.beta.1/spec/integration/
mechanize/spec/spec_helper.rb
My Gemfile looks like this:
$ cat Gemfile
source ‘http://rubygems.org’
gem ‘rails’, ‘3.0.0.rc’
Bundle edge Rails instead:
gem ‘rails’, :git => ‘git://github.com/rails/rails.git’
gem ‘sqlite3-ruby’, :require => ‘sqlite3’
group :development, :test do
gem ‘rspec-rails’, ‘>= 2.0.0.beta.19’
end
I have done a few web searches but I could not find anything to help
me. Any help would be greatly appreciated, I am very anxious to get
started with this wonderful environment! Let me know if there’s any
additional information needed to pinpoint the problem.
Regards,
Daniel
LidströmStockholm, Sweden