[rspec-users] rspec mocha and controller specs without integrated_views

David Chelimsky dchelimsky at gmail.com
Wed May 23 18:17:54 EDT 2007


On 5/23/07, Matt Deiters <mdeiters at msn.com> wrote:
> The ability to choose a mocking framework is great as I prefer mocha, but I
> am have problems.
>
> On my controller specs, I am forced to 'integrate_views' as the following
> code below shows you, the mocking of views is rspec specific. See stub!
> versus mocha's stub
>
>           unless block_given?
>             unless integrate_views?
>               @template.stub!(:file_exists?).and_return(true)
>
> @template.should_receive(:render_template).any_number_of_times.and_return(true)
> { |*args|
>                 @first_render ||= args[2]
>               }
>
> @template.stub!(:find_template_extension_for).and_return("rhtml")
>               @template.stub!(:read_template_file).and_return("this is fake
> content generated by rspec")
>             end
>           end
>
> I am getting the following error: undefined method `stub!'
> Any plans on fixing this?

Sure. Go ahead and raise an RFE in the tracker
(http://rubyforge.org/tracker/?group_id=797). If you want to see it
happen fast, submit a patch. Now that users can use any mock
framework, we should probably not use any mock framework for anything
internal, so the method should just override the methods that are
being mocked.

>
> Matt
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list