[rspec-users] Links in view specs

David Chelimsky dchelimsky at gmail.com
Tue Jan 16 08:21:51 EST 2007


On 1/16/07, Ashley Moran <work at ashleymoran.me.uk> wrote:
> Hi
>
> I have this simple view (used by the Gap controller):
>
>    <h1>Gap#index</h1>
>    <%= link_to "Get a GAP quote", :action => "get_quote" %>
>
> And this spec:
>
>    context "A rendered gap/index" do
>      setup do
>        render 'gap/index'
>      end
>
>      specify "should have a link to the get_quote page" do
>        response.should_have_tag 'a', :attributes => { :href => /\/gap
> \/get_quote/ }
>      end
>    end
>
> But is fails because it actually links like this:
>     <a href="/view_spec/get_quote">
> not
>    <a href="/gap/get_quote">
>
> What's the cleanest way to test links without integrating it into the
> controller?  For now I'm doing...
>    response.should_have_tag 'a', :attributes => { :href => /\/
> get_quote$/ }
>
>   Sorry if this is a FAQ, can't see any posts on the list about it.

Try checking the tracker at ruby forge too. This is a known bug:

http://rubyforge.org/tracker/index.php?func=detail&aid=7795&group_id=797&atid=3149

Cheers,
David

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


More information about the rspec-users mailing list