[rspec-users] Stubbing #javascript_include_tag in a helper spec
David Chelimsky
dchelimsky at gmail.com
Fri Oct 31 18:50:37 EDT 2008
On Fri, Oct 31, 2008 at 5:26 PM, Nick Hoffman <nick at deadorange.com> wrote:
> When writing specs for a helper method, how do you set an expectation for
> #javascript_include_tag ?
>
> describe NeighbourhoodsHelper do
> describe '#initialise_map' do
> it 'should include the "foo" JS file' do
> # expectation here
> helper.foobar
> end
> end
> end
>
> I've tried replacing "# expectation here" with the following, but none of
> them result in the desired behaviour:
>
> ActionView::Helpers::AssetTagHelper.should_receive :javascript_include_tag
> @controller.should_receive :javascript_include_tag
> @controller.instance_eval { @template }.should_receive
> :javascript_include_tag
Assuming that you intend to have a helper method that calls out to
javascript_include_tag, then:
helper.should_receive :javascript_include_tag
Let us know if that works for you.
> Thanks!
> Nick
More information about the rspec-users
mailing list