[rspec-users] assigns[] in trunk

David Chelimsky dchelimsky at gmail.com
Tue Nov 21 08:06:14 EST 2006


Yes. That's in the documentation that will be part of the next
release. The plugin has always worked treating assigns as a hash. I
made it stop working using parens because one part of the system was
allowing parens and the another one wasn't. I wanted to unify them.

On 11/21/06, Marcus Roberts <marcus at marcusr.org.uk> wrote:
> 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
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list