[rspec-users] assign local variable instead of instance variable.

Mathias Stjernström mathias at globalinn.com
Wed Aug 29 16:18:38 EDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Thanks Hans, that worked like a charm!

I did however choose :locals => { :advert => @mock_object } because i  
think it tells me in a much clearer way that i want to assign a local  
value to the view and also the name of the variable.

I do not know if it is possible but what about an assigns_local 
[:advert] => @mock_object ?

This is how it turned out: http://pastie.textmate.org/92166

Cheers!

Mathias Stjernstrom


On 29 aug 2007, at 16.32, Hans de Graaff wrote:

> On Wed, 2007-08-29 at 14:35 +0200, Mathias Stjernström wrote:
>
>> And to describe that: http://pastie.textmate.org/91995
>>
>> The problem is that (assigns[:advert] = advert) creates an instance
>> variable and :collection => @adverts creates a local variable called
>> advert.
>>
>> Is there a way of assigning a local variables in a view/template from
>> my description/spec?
>
> I'm using "render :partial => 'some_partial', :object => @mock_object"
> in those cases.
>
> Kind regards,
>
> Hans
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)

iQEVAwUBRtXUnskN6DtuoU6XAQIuVAf/SUYADCa1NUAXgoxujwrhh+J7qRJDgfDr
3QoyDeEsi3M4C1FjqWblTxy6qcdO5/2hzqgB/vs8EMvsFqm9LbLxWVRIM2DQgl9j
tXVGvFTibCwb8pZnT/8QpNRwXhJQ0Yc1+G5ur1s0svtYGJevwg5Npkc9FMrDhFmI
hqO6cnYOUCPps/2D6YAf0kZxV4UMmhQa7sBCOX2QlJEh3W6uBTX0oZF5GvVyq4Y3
YSSvA/RD/e9ZPVsMwk6rsnRAHt7rrt6zndMJ65j8qAFpFTBPze5p5KAeDrbuKuyy
V8IC2vgvDCSHq1Z34kiM3TONP0tYb6Z/rtvz7F46sAU9AdFfhhEfyA==
=eZvA
-----END PGP SIGNATURE-----


More information about the rspec-users mailing list