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.13 spec/support/matcher.rb
pagseguro-0.1.12 spec/support/matcher.rb
pagseguro-0.1.11 spec/support/matcher.rb
pagseguro-0.1.11.beta2 spec/support/matcher.rb
pagseguro-0.1.11.beta1 spec/support/matcher.rb
pagseguro-0.1.10 spec/support/matcher.rb
pagseguro-0.1.10.beta.0 spec/support/matcher.rb
pagseguro-0.1.9 spec/support/matcher.rb
pagseguro-0.1.9.beta.0 spec/support/matcher.rb
pagseguro-0.1.8 spec/support/matcher.rb
pagseguro-0.1.7 spec/support/matcher.rb
pagseguro-0.1.7.beta.1 spec/support/matcher.rb
pagseguro-0.1.7.beta.0 spec/support/matcher.rb
pagseguro-0.1.6 spec/support/matcher.rb
pagseguro-0.1.5 spec/support/matcher.rb
pagseguro-0.1.4 spec/support/matcher.rb
pagseguro-0.1.3 spec/support/matcher.rb
pagseguro-0.1.3.beta.1 spec/support/matcher.rb
pagseguro-0.1.2 spec/support/matcher.rb
pagseguro-0.1.1 spec/support/matcher.rb