This file is indexed.

/usr/lib/ruby/vendor_ruby/capybara/spec/session/click_link_or_button_spec.rb is in ruby-capybara 2.5.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
Capybara::SpecHelper.spec '#click_link_or_button' do
  it "should click on a link" do
    @session.visit('/with_html')
    @session.click_link_or_button('labore')
    expect(@session).to have_content('Bar')
  end

  it "should click on a button" do
    @session.visit('/form')
    @session.click_link_or_button('awe123')
    expect(extract_results(@session)['first_name']).to eq('John')
  end

  it "should click on a button with no type attribute" do
    @session.visit('/form')
    @session.click_link_or_button('no_type')
    expect(extract_results(@session)['first_name']).to eq('John')
  end

  it "should be aliased as click_on" do
    @session.visit('/form')
    @session.click_on('awe123')
    expect(extract_results(@session)['first_name']).to eq('John')
  end

  it "should wait for asynchronous load", :requires => [:js] do
    @session.visit('/with_js')
    @session.click_link('Click me')
    @session.click_link_or_button('Has been clicked')
  end

  it "casts to string" do
    @session.visit('/form')
    @session.click_link_or_button(:'awe123')
    expect(extract_results(@session)['first_name']).to eq('John')
  end

  context "with :exact option" do
    context "when `true`" do
      it "clicks on approximately matching link" do
        @session.visit('/with_html')
        @session.click_link_or_button('abore', :exact => false)
        expect(@session).to have_content('Bar')
      end

      it "clicks on approximately matching button" do
        @session.visit('/form')
        @session.click_link_or_button('awe')
        expect(extract_results(@session)['first_name']).to eq('John')
      end
    end

    context "when `false`" do
      it "does not click on link which matches approximately" do
        @session.visit('/with_html')
        msg = "Unable to find link or button \"abore\""
        expect do
          @session.click_link_or_button('abore', :exact => true)
        end.to raise_error(Capybara::ElementNotFound, msg)
      end

      it "does not click on approximately matching button" do
        @session.visit('/form')
        msg = "Unable to find link or button \"awe\""

        expect do
          @session.click_link_or_button('awe', :exact => true)
        end.to raise_error(Capybara::ElementNotFound, msg)
      end
    end
  end

  context "with a locator that doesn't exist" do
    it "should raise an error" do
      @session.visit('/with_html')
      msg = "Unable to find link or button \"does not exist\""
      expect do
        @session.click_link_or_button('does not exist')
      end.to raise_error(Capybara::ElementNotFound, msg)
    end
  end

  context "with :disabled option" do
    it "ignores disabled buttons when false" do
      @session.visit('/form')
      expect do
        @session.click_link_or_button('Disabled button', :disabled => false)
      end.to raise_error(Capybara::ElementNotFound)
    end

    it "ignores disabled buttons by default" do
      @session.visit('/form')
      expect do
        @session.click_link_or_button('Disabled button')
      end.to raise_error(Capybara::ElementNotFound)
    end

    it "happily clicks on links which incorrectly have the disabled attribute" do
      @session.visit('/with_html')
      @session.click_link_or_button('Disabled link')
      expect(@session).to have_content("Bar")
    end

    it "does nothing when button is disabled" do
      @session.visit('/form')
      expect do
        @session.click_link_or_button('Disabled button', :disabled => false)
      end.to raise_error(Capybara::ElementNotFound)
    end

  end
end