Sha256: 206d6002b421615ad69a4fd9d96f67d1fffcf88b00db15390d1fe70637a72171

Contents?: true

Size: 757 Bytes

Versions: 12

Compression:

Stored size: 757 Bytes

Contents

RSpec::Matchers.define :have_styling do |rules|
  @selector = 'body > *:first'

  chain :at_selector do |selector|
    @selector = selector
  end

  match do |document|
    if rules.nil?
      parsed_styles(document).blank?
    else
      rules.to_a.should == parsed_styles(document)
    end
  end

  describe { "have styles #{rules.inspect} at selector #{@selector.inspect}" }
  failure_message_for_should { |document| "expected styles at #{@selector.inspect} to be #{rules.inspect} but was #{parsed_styles(document).inspect}" }
  failure_message_for_should_not { "expected styles at #{@selector.inspect} to not be #{rules.inspect}" }

  def parsed_styles(document)
    node = document.css(@selector).first
    SpecHelpers.styling_of_node(node)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
roadie-2.3.3 spec/support/have_styling_matcher.rb
roadie-2.3.2 spec/support/have_styling_matcher.rb
roadie-2.3.1 spec/support/have_styling_matcher.rb
roadie-2.3.0 spec/support/have_styling_matcher.rb
roadie-2.3.0.pre1 spec/support/have_styling_matcher.rb
roadie-2.2.0 spec/support/have_styling_matcher.rb
roadie-2.1.0 spec/support/have_styling_matcher.rb
roadie-2.1.0.pre2 spec/support/have_styling_matcher.rb
roadie-2.1.0.pre1 spec/support/have_styling_matcher.rb
roadie-2.0.0 spec/support/have_styling_matcher.rb
roadie-1.1.3 spec/support/have_styling_matcher.rb
roadie-1.1.2 spec/support/have_styling_matcher.rb