I worked this out

In the view spec you need to do something like this:

 describe "users/index.html.haml" do
   before do

     # this is the bit you need
     view.stub!(:abc).and_return(whatever_your_helper_returns)
     # end of the bit you need

     render
   end
   it "stuff" do
     rendered.should have_selector('whatever')
   end

 end


On Jul 8, 1:12 am, itsterry <itste...@gmail.com> wrote:
> I have a view which calls a helper. Lets' call it "abc"
>
> So in my view, I write
> =abc #(I'm using haml)
>
> When I run the view in my webserver, all works fine
>
> But when I run my view spec, it tells me
>   undefined local variable or method 'abc' for #<#Class:0xnumbers>
>
> I've googled this, but can't find the right way to tell the spec to
> access the helper. Any clues, anyone?
>
> If it helps, here's (an edited version of) the view spec code:
>
> describe "users/index.html.haml" do
>   before do
>     render
>   end
>   it "stuff" do
>     rendered.should have_selector('whatever')
>   end
>
> end
>
> TIA for any help
>
> T
>
> _______________________________________________
> rspec-users mailing list
> rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to