Sha256: 6fbf16e707c2a061b9e26e408de2413ba0a656451ff0ef8c735584f8bd35591d

Contents?: true

Size: 979 Bytes

Versions: 21

Compression:

Stored size: 979 Bytes

Contents

RSpec::Matchers.define :have_input do |options|
  match do |html|
    options.reverse_merge!(:type => "hidden")

    selector = "input"
    selector << "[type=#{options[:type]}]"
    selector << "[name=#{options[:name]}]" if options[:name]

    input = html.css(selector).first

    if options[:value]
      input && input[:value] == options[:value]
    else
      input != nil
    end
  end

  failure_message_for_should do |html|
    "expected #{html.to_s} to have a field with attributes #{options.inspect}"
  end

  failure_message_for_should_not do |html|
    "expected #{html.to_s} to have no field with attributes #{options.inspect}"
  end
end

RSpec::Matchers.define :have_attr do |name, value|
  match do |html|
    html[name] == value
  end

  failure_message_for_should do |html|
    "expected #{html.to_s} to have a #{name.inspect} with value #{value.inspect}"
  end

  description do
    "should have attribute #{name.inspect} with value #{value.inspect}"
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
pagseguro-0.1.0 spec/support/matcher.rb