Wednesday, December 08, 2010

Moving from rspec 2.0.0.beta.18 to rspec 2.0.0.beta.22

This post is primarily for anyone who is using rspec 2.0.0.beta.18 as specified in the Ruby on Rails Tutorial and find that they hit upon the following problem:

Failure/Error: Unable to find C to read failed line
undefined method `get' for # do
include RSpec::Rails::RequestExampleGroup

Whenever they run the tests:
$ rspec spec/requests/layout_links_spec.rb
To fix this, I installed rspec 2.0.0.beta.22 by using the command:
$ gem install rspec -v 2.0.0.beta.22 --pre
Then I changed the version of rspec specified in my Gemfile as:
$ git diff Gemfile
WARNING: terminal is not fully functional
diff --git a/Gemfile b/Gemfile
index 28af226..865b9de 100644
--- a/Gemfile
+++ b/Gemfile
@@ -30,10 +30,11 @@ gem 'sqlite3-ruby', :require => 'sqlite3'
# end

group :development do
- gem 'rspec-rails', '2.0.0.beta.18'
+ gem 'rspec-rails', '2.0.0.beta.22'
end

group :test do
- gem 'rspec', '2.0.0.beta.18'
+ gem 'rspec', '2.0.0.beta.22'
end

warning: LF will be replaced by CRLF in Gemfile.
The file will have its original line endings in your working directory.
Then I installed this version of rspec using the command:
$ bundle install

Now I got a new error:
1) LayoutLinks should have a Home page at '/'
Failure/Error: response.should have_selector('title', :content => "Home")
undefined method `has_selector?' for #
# ./spec/requests/layout_links_spec.rb:6:in `block (2 levels) in '
Google suggested the solution in this page: Add "webrat" the Gemfile, do a bundle install and that should do it.

In my case, I had to uncomment the entry in the Gemfile.
$ git diff Gemfile
WARNING: terminal is not fully functional
diff --git a/Gemfile b/Gemfile
index 28af226..ea7d729 100644
--- a/Gemfile
+++ b/Gemfile
@@ -25,15 +25,16 @@ gem 'sqlite3-ruby', :require => 'sqlite3'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
-# group :development, :test do
-# gem 'webrat'
-# end
+group :development, :test do
+ gem 'webrat'
+end

group :development do
- gem 'rspec-rails', '2.0.0.beta.18'
+ gem 'rspec-rails', '2.0.0.beta.22'
+# gem 'annotate-models', '1.0.4'
end

group :test do
- gem 'rspec', '2.0.0.beta.18'
+ gem 'rspec', '2.0.0.beta.22'
end

warning: LF will be replaced by CRLF in Gemfile.
The file will have its original line endings in your working directory.
That fixed it!

Cheers!
Karthick S.
Post a Comment