On Jun 22, 2010, at 8:27 AM, Michael Schuerig wrote:

> On Sunday 20 June 2010, Michael Schuerig wrote:
>> Are partial mocks supposed to work in rails-rspec 2.0.0.beta.12?
>> 
>> I'm trying to do things like
>> 
>>  view.stub(:current_user).and_return(@user)
>>  view.stub(:current_page?).and_return(false)
>> 
>> However, when I do that, the view uses its "ordinary" functionality,
>> in  particular, assigns are no longer available as instance
>> variables.
> 
> I've found the reason:
> 
> rspec-
> rails-2.0.0.beta.12/lib/rspec/rails/monkey/action_view/test_case.rb
> 
>  def _view
>    @_view ||= begin
>      view = ActionView::Base.new(ActionController::Base.view_paths,
>                                  _assigns, @controller)
>      ...
>      view
>    end
>  end
> 
> #_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.
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to