[rspec-users] assigns[] in trunk

Marcus Roberts marcus at marcusr.org.uk
Tue Nov 21 05:38:45 EST 2006


Hello,

I used the rspec_resource_generator to generate a set of specs, which  
produces quite a few specs that contain something like:

assigns(:customer).should == @customer

running this gives the error:

wrong number of arguments (1 for 0)
./spec/controllers/customers_controller_spec.rb:23:in `assigns'


In the rspec rails plugin trunk (revision 1126), in /lib/spec/rails/ 
context/controller.rb, assigns is defined as:

   def assigns
         @ivar_proxy ||= Spec::Rails::IvarProxy.new @controller
   end

whereas if i get the tagged version for 0_7_2  it was defined thus:

def assigns(key=nil)
           return assigns[key] unless key.nil?
          @ivar_proxy ||= Test::Rails::IvarProxy.new(controller)
end


So, if I change the code in my spec to

assigns[:customer].should == @customer

it works.

Is this the right thing to do at the moment for the trunk version of  
rspec and the plugin?

Thanks

Marcus




More information about the rspec-users mailing list