title: select specific link by href with webrat
body: <p>I'm writing an integration test for rspec and I want to test that clicking on a link goes to the correct model page. More specifically, I want to test this on a list of links that have the same name but different underlying URLs. </p>
  
  <p>From what I've learned so far, you cannot use a css attribute selector with click_link as it only looks for specific text or dom ID. Instead I'm trying to use the webrat <code>within</code> method, but once I select the link how do I click it? I figured <code>link.click</code> within the link's scope would work, but it fails saying the method <code>click</code> is undefined:</p>
  
  <pre><code>Failure/Error: link.click
  NoMethodError:
    undefined method `click' for #&lt;Webrat::Scope:0x0000010505ae00&gt;
  </code></pre>
  
  <p>Here's my test:</p>
  
  <pre><code>require 'spec_helper'
  
  describe "BrandLinks" do
    before(:each) do
      @base_title = "My App - "
  
      @brand = Factory(:brand)
      second = Factory(:brand) # &lt;= Same name, different slug
      third = Factory(:brand, :name =&gt; "Awesome USA Brand!!")
      @brands = [@brand, second, third]
    end
  
    it "should show me the brand page when I click on a brand link" do
      get '/brands'
      within "a[href=#{brand_path(@brand)}]" do |link|
        link.click
      end
      response.should be_success
      response.should have_selector(
        "title", 
        :content =&gt; "#{@base_title}Brand - #{@brand.name}"
      )
    end
  end
  </code></pre>