Installing RSpec for Rails 3

Wed Apr 14 20:48:06 -0700 2010

Installing RSpec for Rails 3 was quite simple, here is a short guide to make sure you can also do it :)

For a Rails 3 app, simply edit the Gemfile and put this into the test section:

group :test do
  gem "rspec-rails",      ">= 2.0.0.beta"
  gem "autotest"
  gem "autotest-rails"
end

Then from your Rails root do:

$ bundle install

Once installed, you will need to tell RSpec to install itself:

 $ script/rails g rspec:install
       exist  lib
      create  lib/tasks/rspec.rake
       exist  config/initializers
      create  config/initializers/rspec_generator.rb
       exist  spec
      create  spec/spec_helper.rb
      create  autotest
      create  autotest/discover.rb

Then you should just be able to run Autotest:

 $ autotest
loading autotest/rails_rspec2
style: RailsRspec2
/Users/mikel/.rvm/rubies/ruby-1.8.7-p249/bin/ruby <snip>
........

Finished in 0.30205 seconds
8 examples, 0 failures

Nice.

blogLater

Mikel

  1. puterecom Says:

    On a related note. It seems the RSpec bundle for TextMate needs updating. The bundle’s spec file generator (shift+control+down_arrow) is inserting the spec stub code into the source file instead of the generated spec file.

  2. shingara Says:

    Rspec 2.0 is full compatible to Rails 3 ? or not now ?

  3. Sohan Says:

    Your post has been linked at the Drink Rails blog roll for the day.

  4. Jose Says:

    Thanks for the info.

    On a related note. It seems the RSpec bundle for TextMate needs updating. The bundle’s spec file generator (shift+control+down_arrow) is inserting the spec stub code into the source file instead of the generated spec file.

  5. daniel Says:

    Got this after following the steps:

    $ autotest
    loading autotest/rails_rspec2
    Error loading Autotest style autotest/rails_rspec2 (no such file to load — autotest/rails_rspec2). Aborting.

    help appriciated.

  6. Bluelock Says:

    I did not realize that this was simple. It is encouraging to see you guys doing this sort of thing. I will take a look and see if the benefits will be worthwhile for me. Thanks for posting these instructions.

  7. boys bikes Says:

    Such an amazing blog you have posted dear i like it and also suggesting it to my friends for visiting your blog because it has really admirable and informative data which provide us through your blog so i would like to thank you for sharing it with us and also appreciate you on this so keep it up.

  8. Mike Says:

    Want to know Rspec 2.0 is full compatible to Rails 3 ?

  9. boys bikes Says:

    Such an amazing blog you have posted dear i like it and also suggesting it to my friends for visiting your blog because it has really admirable and informative data which provide us through your blog so i would like to thank you for sharing it with us and also appreciate you on this so keep it up.

  10. simon Says:

    I am appreciating it very much! Looking forward to another great blog. Good luck to the author! all the best!
    chefs clothing

  11. how to become a pilot Says:

    About this topic, I have been lately in your blog once or twice now. I just wanted to say hi and show my thanks for the information provided.

  12. how to become a pilot Says:

    About this topic, I have been lately in your blog once or twice now. I just wanted to say hi and show my thanks for the information provided.

Leave a Reply