Updating to 3.1.1 following RailsTutorial.org screencast
I am following the lesson 13 screencast from Railstutorial.org and am hung up on the error below:
Failures:
1) PagesController GET 'home' when signed in should have the right follower/following counts
Failure/Error: response.should have_selector('a', :href => following_user_path(@user),
expected following output to contain a <a href='/users/1/following'>0 following</a> tag:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Ruby on Rails Tutorial Sample App | Home</title>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]--><link href="/assets/blueprint/screen.css" media="screen" rel="stylesheet" type="text/css">
<link href="/assets/blueprint/print.css" media="print" rel="stylesheet" type="text/css">
<!--[if lt IE 8]><link href="/assets/blueprint/ie.css" media="screen" rel="stylesheet" type="text/css" /><![endif]--><link href="/assets/custom.css" media="screen" rel="stylesheet" type="text/css">
<script src="/assets/defaults.js" type="text/javascript"></script>
</head>
<body>
<div class="container">
<header><a href="/"><img alt="Sample App" class="round" src="/assets/logo.png"></a>
<nav class="round"><ul>
<li> <a href="/">Home</a>
</li>
<li> <a href="/help">Help</a>
</li>
<li> <a href="/signin">Sign in</a>
</li>
</ul></nav></header><section class="round"><h1>Home</h1>
<p>Find me in app/views/pages/home.html.erb</p>
<a href="/signup" class="signup_button round">Sign up now!</a>
</section><footer><nav class="round"><ul>
<li> <a href="/about">About</a> </li>
<li> <a href="/contact">Contact</a> </li>
<li> <a href="http://news.railstutorial.org/">News</a> </li>
<li> <a href="http://railstutorial.org/">About</a> </li>
</ul></nav></footer>
</div>
</body>
</html>
# ./spec/controllers/pages_controller_spec.rb:119:in `block (4 levels) in <top (required)>'
Finished in 7.32 seconds
10 examples, 1 failure
Failed examples:
rspec ./spec/controllers/pages_controller_spec.rb:117 # PagesController GET 'home' when signed in should have the right follower/following counts
my gemfile:
source 'http://rubygems.org'
gem 'rack' , '1.3.3'
gem 'rails', '3.1.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'gravatar_image_tag', '1.0.0.pre2'
# gem 'will_paginate', '3.0.pre2'
gem 'will_paginate', '~> 3.0.2'
gem 'sqlite3', '1.3.4'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :development do
gem 'rspec-rails', '2.7.0'
# gem 'annotate-models', '1.0.4'
gem 'annotate', '2.4.0'
gem 'faker', '0.3.1'
end
group :test do
gem 'rspec-rails', '2.7.0'
gem 'webrat', '0.7.1'
gem 'spork', '0.9.0.rc8'
gem 'factory_girl_rails', '1.0'
# gem 'autotest', '4.4.6'
# gem 'autotest-rails-pure', '4.1.2'
# gem 'autotest-fsevent', '0.2.4'
# gem 'autotest-growl', '0.2.9'
end
Wondering possibly if its an rspec version problem? --
pages_controller_spec.rb
it "should have the right follower/following counts" do
get :home
response.should have_selector('a', :href => following_user_path(@user),
:content => "0 following")
response.should have_selector('a', :href => followers_user_path(@user),
:content => "1 follower")
end
pages_controller.rb
class PagesController < ApplicationController
def home
@title = "Home"
if signed_in?
@micropost = Micropost.new
@feed_items = current_user.feed.paginate(:page => params[:page])
end
end
def contact
@title = "Contact"
end
def about
@title = "About"
end
def help
@title = "Help"
end
end
when I comment out the pages_controller_spec.rb section I go green
Any thoughts?
Update 1:
Changing RSPEC versions did not work, tried 2.4.0, 2.6.1 and 2.6.4
Update 2:
Changing to Rails 3.1.0 did not work
Update 3:
Triple Checked running rspec in original sample ap开发者_StackOverflowp Rails 3.0.8 GREEN
update 4:
home page
<% if signed_in? %>
<table class="front" summary="For signed-in users">
<tr>
<td class="main">
<h1 class="micropost"> What's up? </h1>
<%= render 'shared/micropost_form' %>
<%= render 'shared/feed'%>
</td>
<td class="sidebar round">
<%= render 'shared/user_info' %>
<%= render 'shared/stats' %>
</td>
</tr>
</table>
<% else %>
<h1>Home</h1>
<p>Find me in app/views/pages/home.html.erb</p>
<%= link_to "Sign up now!", signup_path, :class => "signup_button round" %>
<% end %>
The error message suggests that when a user visits /pages/home
they should see a link constructed from the following code:
<a href='/users/1/following'>0 following</a>
Do you actually see that link when you visit the home page?
If not, then you should add it, I'd imagine there's a section or chapter where the author walks you through doing that.
精彩评论