[rspec-users] assigns in RSpec 2 - deprecation warning on rendered?

Kristian Mandrup kmandrup at gmail.com
Wed Jun 9 17:28:26 EDT 2010

> assign(:message, stub("Message"))
> That should get rid of your deprecation message.

Yeah! But strange deprecation message that it mentions:
* response is deprecated.
* please use rendered instead.

When it should be:
* assigns is deprecated.
* please use assign instead.

Also, how do I use this assigned message

In my show view I have:
<%=h @message.text %>

When I run it now:

    assign(:message, stub("Message"))
    puts "@message: #{@message.inspect}"

@message: nil <--------- OUCH!!!

1) messages/show.html.erb displays the text attribute of the message
    Failure/Error: Unable to find matching line from backtrace
    Stub "Message" received unexpected message :text with (no args)

@message is nil after using assigns! But inside the view it seems at
least to recognize the stub called "Message"?

Now if I inspect @message in the view instead
<%=h @message.inspect %>

expected the following element's content to include "Hello world!":
    #<RSpec::Mocks::Mock:0x81952668 @name="Message">

Now I just need to find out how to extract the text from the Stub
message... ?

More information about the rspec-users mailing list