Sha256: 03b4932c87067ed169bfb009096ba874db9c0b923308536ea5e38fbe1287264f

Contents?: true

Size: 1.7 KB

Versions: 23

Compression:

Stored size: 1.7 KB

Contents

require 'mechanize/test_case'

class TestMechanizeFormField < Mechanize::TestCase

  def test_inspect
    field = node 'input'
    field = Mechanize::Form::Field.new field, 'a&b'

    assert_match "value: a&b", field.inspect
  end

  def test_name
    field = node 'input', 'name' => 'a&b'
    field = Mechanize::Form::Field.new field

    assert_equal 'a&b', field.name
  end

  def test_name_entity
    field = node 'input', 'name' => 'a&amp;b'
    field = Mechanize::Form::Field.new field

    assert_equal 'a&b', field.name
  end

  def test_name_entity_numeric
    field = node 'input', 'name' => 'a&#38;b'
    field = Mechanize::Form::Field.new field

    assert_equal 'a&b', field.name
  end

  def test_spaceship
    doc = Nokogiri::HTML::Document.new
    node = doc.create_element('input')
    node['name'] = 'foo'
    node['value'] = 'bar'

    a = Mechanize::Form::Field.new(node)
    b = Mechanize::Form::Field.new({'name' => 'foo'}, 'bar')
    c = Mechanize::Form::Field.new({'name' => 'foo'}, 'bar')

    assert_equal [a, b], [a, b].sort
    assert_equal [a, b], [b, a].sort
    assert_equal [b, c].sort, [b, c].sort
  end

  def test_value
    field = node 'input'
    field = Mechanize::Form::Field.new field, 'a&b'

    assert_equal 'a&b', field.value
  end

  def test_value_entity
    field = node 'input'
    field = Mechanize::Form::Field.new field, 'a&amp;b'

    assert_equal 'a&b', field.value
  end

  def test_value_entity_numeric
    field = node 'input'
    field = Mechanize::Form::Field.new field, 'a&#38;b'

    assert_equal 'a&b', field.value
  end

  def test_raw_value
    field = node 'input'
    field = Mechanize::Form::Field.new field, 'a&amp;b'

    assert_equal 'a&amp;b', field.raw_value
  end

end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
mechanize-2.10.0 test/test_mechanize_form_field.rb
mechanize-2.9.2 test/test_mechanize_form_field.rb
mechanize-2.9.1 test/test_mechanize_form_field.rb
mechanize-2.9.0 test/test_mechanize_form_field.rb
mechanize-2.8.5 test/test_mechanize_form_field.rb
mechanize-2.8.4 test/test_mechanize_form_field.rb
mechanize-2.8.3 test/test_mechanize_form_field.rb
mechanize-2.8.2 test/test_mechanize_form_field.rb
mechanize-2.8.1 test/test_mechanize_form_field.rb
mechanize-2.8.0 test/test_mechanize_form_field.rb
mechanize-2.7.7 test/test_mechanize_form_field.rb
husc-0.2.1 vendor/bundle/gems/mechanize-2.7.6/test/test_mechanize_form_field.rb
husc-0.2.0 vendor/bundle/gems/mechanize-2.7.6/test/test_mechanize_form_field.rb
husc-0.1.1 vendor/bundle/gems/mechanize-2.7.6/test/test_mechanize_form_field.rb
husc-0.1.0 vendor/bundle/gems/mechanize-2.7.6/test/test_mechanize_form_field.rb
mechanize-2.7.6 test/test_mechanize_form_field.rb
mechanize-2.7.5 test/test_mechanize_form_field.rb
mechanize-2.7.4 test/test_mechanize_form_field.rb
mechanize-2.7.3 test/test_mechanize_form_field.rb
mechanize-2.7.2 test/test_mechanize_form_field.rb