Sha256: 0ec7099e29886278953b70fde8f5f5775393f197a7785fd5b39ad2619933bc39

Contents?: true

Size: 888 Bytes

Versions: 4

Compression:

Stored size: 888 Bytes

Contents

require 'rspec/expectations'


RSpec::Matchers.define :have_class do |expected_|
  match do |actual|
    actual.match(/class\=(?:"|').*(#{expected}).*(?:"|')/)
    $1.present?
  end
  
  description do
      "have CSS class \"#{expected}\""
    end
  
  failure_message do |actual|
    "expected #{actual} to have CSS class \"#{expected}\""
  end
  
  failure_message_when_negated do |actual|
    "expected #{actual} not to have CSS class \"#{expected}\""
  end
  
end

RSpec::Matchers.define :have_id do |expected_|
  match do |actual|
    actual.match(/id\=(?:"|')(#{expected})(?:"|')/)
    $1.present?
  end
  
  description do
      "have CSS id \"#{expected}\""
    end
  
  failure_message do |actual|
    "expected #{actual} to have CSS id \"#{expected}\""
  end
  
  failure_message_when_negated do |actual|
    "expected #{actual} not to have CSS id \"#{expected}\""
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
blogit-1.1.2 spec/support/helpers/css_matchers.rb
blogit-1.1.1 spec/support/helpers/css_matchers.rb
blogit-1.1.0 spec/support/helpers/css_matchers.rb
blogit-1.0.0 spec/support/helpers/css_matchers.rb