Sha256: e6ad413bc0d4b1b22c13821c28aa03be331c22c1e080b580943f156c0fb892c5

Contents?: true

Size: 511 Bytes

Versions: 6

Compression:

Stored size: 511 Bytes

Contents

RSpec::Matchers.define :have_css do |expected, times|
  match do |actual|
    selector = HTML::Selector.new(expected).select(actual)
    if times
      expect(selector.size).to eq times
    else
      expect(selector.size).to be >= 1
    end
  end

  failure_message do |actual|
    "expected #{actual.to_s} to have #{times || 1} elements matching '#{expected}'"
  end

  failure_message_when_negated do |actual|
    "expected #{actual.to_s} not to have #{times || 1} elements matching '#{expected}'"
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
simple-navigation-4.0.5 spec/initializers/have_css_matcher.rb
simple-navigation-4.0.4 spec/initializers/have_css_matcher.rb
simple-navigation-4.0.3 spec/initializers/have_css_matcher.rb
simple-navigation-4.0.2 spec/initializers/have_css_matcher.rb
simple-navigation-4.0.1 spec/initializers/have_css_matcher.rb
simple-navigation-4.0.0 spec/initializers/have_css_matcher.rb