I\'m following the rails tutorial here: http://railstutorial.org/chapters/filling-in-the-layout#top
When I run \"rspec spec/\", I get a bunch of errors that look lik
my gemfile looked like this and it works
group :test do
gem 'rspec-rails'
gem 'webrat', '0.7.1'
end
where rspec-rails (2.1.0)
however following doesn't:
group :test do
gem 'rspec-rails'
gem 'webrat', '0.7.2'
end
So I think it is webrat plays up.
I was still seeing this issue until I specified webrat 0.7.1.
The following fixed the problem for me.
gem install rspec-rails
sudo apt-get install libxslt-dev libxml2-dev
bundle install
rails generate rspec:install
I upgraded to beta.20 which is now out. Had to add webrat into my gemfile and do another bundle install. In the gemfile, it looks like this:
group :test do
gem "webrat"
gem 'rspec', '2.0.0.beta.20'
end
Cheers
I am only seeing this issue for two of my title tests.
My gemfile is as follows...
source 'http://rubygems.org'
gem 'rails', '3.0.0'
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
gem 'gravatar_image_tag', '0.1.0'
gem 'will_paginate', '3.0.pre2'
group :development do
gem 'rspec-rails', '2.0.0.rc'
gem 'webrat', '0.7.1'
gem 'annotate-models', '1.0.4'
gem 'faker', '0.3.1'
end
group :test do
gem 'rspec', '2.0.0.rc'
gem 'webrat', '0.7.1'
gem 'spork', '0.8.4'
gem 'factory_girl_rails', '1.0'
end
I've tried the betas for rspec-rails as well, to no avail.
The two of the titles that are still giving me errors are the following:
From users_controller_spec.rc
it "should have the right title" do
get :index
response.should have_selector("title", :content => "All users")
end
#...
it "should have the right title" do
post :create, :user => @attr
response.should have_selector("title", :content => "Sign up")
end
The snippet from the errors reads:
Failures:
1) UsersController GET 'index' for signed-in users should have the right title
Failure/Error: response.should have_selector("title", :content => "All users")
expected following output to contain a <title>All users</title> tag:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Ruby on Rails Tutorial Sample App | All Users</title>
and
2) UsersController Post 'create' for non-signed in users failure should have the right title
Failure/Error: response.should have_selector("title", :content => "Sign up")
expected following output to contain a <title>Sign up</title> tag:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Ruby on Rails Tutorial Sample App | Sign Up</title>
respectively.
As seen by the output, "Sign Up" and "Index" are clearly shown to the right of the title. This is particularly perplexing in that, the following test does work:
it "should have the right title" do
get :new
response.should have_selector("title", :content => "Sign up")
end
Which is for the same page and contains the same title as the other "Sign Up" test. Also the get method works in this test but not in the "Index" test.
Help?