Following the RailsTutorial, I keep getting this error message (one of four actually) when it should be working:
UsersController authentication of edit/update pages for signed-in
users should require matching users for 'edit'
Failure/Error: @users = [@user, second, third] undefined local variable
or method 'second' for
#<RSpec::Core::ExampleGroup::Nested_3::Nested_7::Nested_2:0x000001040dcb68> #
./spec/controllers/users_controller_spec.rb:275:in 'block
(4 levels) in <top (required)>'
I have tried to fix it by looking at other questions on stack overflow but to no avail. My gemfile now looks like this:
gem 'rails', '3.0.3'
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.1'
gem 'annotate-models', '1.0.4'
gem 'faker', '0.3.1'
end
group :test do
gem 'rspec-rails', '2.0.1'
gem 'webrat', '0.7.1'
gem 'spork', '0.8.4'
gem 'factory_girl_rails', '1.0'
end
Any suggestions would be greatly appreciated!
The backtrace is coming from the users_controller_spec. Without the source, it’s hard to say, but I’m guessing it’s something like this:
Note that the variables shared between #before blocks and the examples are instance variables – local variables wouldn’t be shared across them. I’m guessing your code might be trying to share a local between examples, or between a #before block and its examples.