I am using Ruby 1.9.2 and Rails 3.0.3
I am consistently getting failing test errors within this tutorial such as:
1) UsersController GET 'show' should show the user's micropost
Failure/Error: get :show, :id => @user
undefined method `model_name' for NilClass:Class
# ./app/views/users/show.html.erb:10:in `_app_views_users_show_html_erb__2659465448390875355_2173812560_4463455946834160058'
# ./spec/controllers/users_controller_spec.rb:39:in `block (3 levels) in <top (required)>'
show.html.erb:10 is:
<% unless @user.microposts.empty? %>
<table class="microposts" summary="User microposts">
<%= render @microposts %> #line 10
</table>
<%= will_pagination @microposts %>
<% end %>
users_controller_spec.rb:39 is:
describe "GET 'show'" do
before(:each) do
@user = Factory(:user)
end
.
.
.
it "should show the user's micropost" do
mp1 = Factory(:micropost, :user => @user, :content => "Foo bar")
mp2 = Factory(:micropost, :user => @user, :content => "Baz quux")
get :show, :id => @user
response.should have_selector("span.content", :content => mp1.cntent)
response.should have_selector("span.content", :content => mp2.content)
end
and my app/controllers/users_controller.rb where is defines micropost is:
def show
@user = User.find(params[:id])
@microposts = @user.microposts.paginate(:page => params[:page])
@title = @user.name
end
any help would be greatly appreciated. I have a total of 14 errors. My other errors are about
Failure/Error: get :edit, :id => @user
@controller is nil: make sure you set it in your test's setup method.
and
Failure/Error: test_sign_in(wrong_user)
undefined method `sign_in' for nil:NilClass
I am also using Factory as a test sign in. Im not sure if this could be a problem. I mention this because some of the errors are:
9) authentication of edit/update pages GET 'index' for signed-in users should have the right title
Failure/Error: @user = test_sign_in(Factory(:user))
Validation failed: Email has already been taken
# ./spec/controllers/users_controller_spec.rb:222:in `block (4 levels) in <top (required)>'
If you need to see anymore code please let me know.
If someone could direct me to a place to learn more about debugging, that would be a big help as well.
For error 1 try checking your filenames for spelling and case.
For error 9 try double checking which do..end you paste your code into.
Working code for the tutorial can be found here https://github.com/railstutorial