[rspec-users] RSpec 2 view specs: partial mocks

Michael Schuerig michael at schuerig.de
Tue Jun 22 10:58:03 EDT 2010

On Tuesday 22 June 2010, David Chelimsky wrote:
> On Jun 22, 2010, at 8:27 AM, Michael Schuerig wrote:

> > #_view (and #view in turn) creates just one ActionView::Base
> > instance the first time it is called. That's as it is intended.
> > The effect is, however, that only assigns up to that point are
> > passed to that instance. Consequently, later assigns are ignored.
> Stubs and assigns are unrelated, so even though this might be a bug,
> I don't think it's the cause of what you're seeing.

It is. If I put all the assign(:x, value) before I first access #view, 
everything works as expected. The problem I had is entirely unrelated to 
stubs. It's just that when I do things in this order

assign(:bar, 10)

The assign doesn't have an effect. I might as well have

view.flash[:notice] = 'Something is rotten.'
assign(:bar, 10)

and the effect would be the same. Assigns that come after the view is 
first initialized are ignored.


Michael Schuerig
mailto:michael at schuerig.de

More information about the rspec-users mailing list