views:

366

answers:

2

I am trying to install rspec-rails on Ubuntu but I am encountering some problems.

Here are my exact steps:

1) Changed my Gemfile to:

source 'http://rubygems.org'

gem 'rails', '3.0.0.beta4'
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'

group :development do
  gem 'rspec-rails', '2.0.0.beta.17'
end

group :test do
  gem 'rspec', '2.0.0.beta.17'
end

2) Type "bundle install" and I get the following error:

/usr/lib/ruby/1.8/fileutils.rb:243:in `mkdir': Permission denied - /home/steve/.gem/specs (Errno::EACCES)

3) If I continue with my installation instructions and type "rails generate rspec:install" I get the following error (but it might have been caused by #2 failing)

Could not find gem 'rspec (= 2.0.0.beta.17, runtime)' in the gems available on this machine.

I was unable to find a solution for this on Google. This is the link to the tutorial I am trying to follow. My dev enviroment is Ubuntu 10.04, Ruby 1.8.7, Rails 3.0.0 beta 4.

Thanks.

+1  A: 

You probably have a permission misconfiguration in your .gem folder. You can reset the permissions using

$ sudo chown -R steve:steve ~/.gem

or you can easily remove the folder and let bundler/rubygems recreate it.

Simone Carletti
+1  A: 

Shouldn't you have rspec being included in the development config too?

I can't test here - but I reckon if you include:

gem 'rspec', '2.0.0.beta.17'

...in your group :development do...end block, that might fix the issue. It would seem logical to me as I think rspec-rails needs the rspec functionality itself in order to be able to generate the necessary files. You're probably safer as well if you make the blocks like this:

group :development do
  gem 'rspec', '2.0.0.beta.17'
  gem 'rspec-rails', '2.0.0.beta.17'
end

group :test do
  gem 'rspec', '2.0.0.beta.17'
  gem 'rspec-rails', '2.0.0.beta.17'
end

...as that way the necessary files should be getting included in both environments. I don't know for sure, I just hope this hasn't confused matters further (I'm a total Rails newbie!)

Stephen Orr
I agree, I'm pretty sure they need to be together.
Tim