This file is indexed.

/usr/lib/ruby/vendor_ruby/capybara/spec/session/element/matches_selector_spec.rb is in ruby-capybara 2.10.2-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
Capybara::SpecHelper.spec '#match_selector?' do
  before do
    @session.visit('/with_html')
    @element = @session.find('//span', text: '42')
  end

  it "should be true if the element matches the given selector" do
    expect(@element).to match_selector(:xpath, "//span")
    expect(@element).to match_selector(:css, 'span.number')
    expect(@element.matches_selector?(:css, 'span.number')).to be true
  end

  it "should be false if the element does not match the given selector" do
    expect(@element).not_to match_selector(:xpath, "//div")
    expect(@element).not_to match_selector(:css, "span.not_a_number")
    expect(@element.matches_selector?(:css, "span.not_a_number")).to be false
  end

  it "should use default selector" do
    Capybara.default_selector = :css
    expect(@element).not_to match_selector("span.not_a_number")
    expect(@element).to match_selector("span.number")
  end

  context "with text" do
    it "should discard all matches where the given string is not contained" do
      expect(@element).to match_selector("//span", text: "42")
      expect(@element).not_to match_selector("//span", text: "Doesnotexist")
    end
  end

  it "should have css sugar" do
    expect(@element.matches_css?('span.number')).to be true
    expect(@element.matches_css?('span.not_a_number')).to be false
    expect(@element.matches_css?('span.number', text: "42")).to be true
    expect(@element.matches_css?('span.number', text: "Nope")).to be false
  end

  it "should have xpath sugar" do
    expect(@element.matches_xpath?("//span")).to be true
    expect(@element.matches_xpath?("//div")).to be false
    expect(@element.matches_xpath?("//span", text: '42')).to be true
    expect(@element.matches_xpath?("//span", text: 'Nope')).to be false
  end

  it 'should accept selector filters' do
    @session.visit('/form')
    cbox = @session.find(:css, '#form_pets_dog')
    expect(cbox.matches_selector?(:checkbox, id: 'form_pets_dog', option: 'dog', name: 'form[pets][]', checked: true)).to be true
  end

  it 'should accept a custom filter block' do
    @session.visit('/form')
    cbox = @session.find(:css, '#form_pets_dog')
    expect(cbox.matches_selector?(:checkbox){ |node| node[:id] == "form_pets_dog"}).to be true
    expect(cbox.matches_selector?(:checkbox){ |node| node[:id] != "form_pets_dog"}).to be false
  end
end

Capybara::SpecHelper.spec '#not_matches_selector?' do
  before do
    @session.visit('/with_html')
    @element = @session.find(:css, "span", text: 42)
  end

  it "should be false if the given selector matches the element" do
    expect(@element).not_to not_match_selector(:xpath, "//span")
    expect(@element).not_to not_match_selector(:css, "span.number")
    expect(@element.not_matches_selector?(:css, "span.number")).to be false
  end

  it "should be true if the given selector does not match the element" do
    expect(@element).to not_match_selector(:xpath, "//abbr")
    expect(@element).to not_match_selector(:css, "p a#doesnotexist")
    expect(@element.not_matches_selector?(:css, "p a#doesnotexist")).to be true
  end

  it "should use default selector" do
    Capybara.default_selector = :css
    expect(@element).to not_match_selector("p a#doesnotexist")
    expect(@element).not_to not_match_selector("span.number")
  end

  context "with text" do
    it "should discard all matches where the given string is contained" do
      expect(@element).not_to not_match_selector(:css, "span.number", text: "42")
      expect(@element).to not_match_selector(:css, "span.number", text: "Doesnotexist")
    end
  end

  it "should have CSS sugar" do
    expect(@element.not_matches_css?("span.number")).to be false
    expect(@element.not_matches_css?("p a#doesnotexist")).to be true
    expect(@element.not_matches_css?("span.number", text: "42")).to be false
    expect(@element.not_matches_css?("span.number", text: "Doesnotexist")).to be true
  end

  it "should have xpath sugar" do
    expect(@element.not_matches_xpath?("//span")).to be false
    expect(@element.not_matches_xpath?("//div")).to be true
    expect(@element.not_matches_xpath?("//span", text: "42")).to be false
    expect(@element.not_matches_xpath?("//span", text: "Doesnotexist")).to be true
  end
end if Gem::Version.new(RSpec::Expectations::Version::STRING) >= Gem::Version.new('3.1')