If you want to use your assigned message within your spec, you can assign it to a variable in the assign call, e.g.
assign(:message, @message = stub('message'). Since you're calling text on the message in your view, you should stub that method: assign(:message, @message = stub('message', :text => 'hello world'). As to the deprecation message, if you're still using response, you should be using rendered. The message is correct. Hope the helps ya, Trey On Wed, Jun 9, 2010 at 3:28 PM, Kristian Mandrup <kmand...@gmail.com> wrote: > > 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}" > render > > > @message: nil <--------- OUCH!!! > F > > 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... ? > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users