Sha256: 8d727156cb7260107dfe5796ed071f2cc722854f9ea590b4f527658defe830eb

Contents?: true

Size: 1.03 KB

Versions: 23

Compression:

Stored size: 1.03 KB

Contents

require 'mechanize/test_case'

class TestMechanizeFormOption < Mechanize::TestCase

  def setup
    super

    page = html_page <<-BODY
<form name="form1" method="post" action="/form_post">
  <select name="select">
    <option value="1">Option 1</option>
    <option value="2" selected>Option 2</option>
  </select>
</form>
    BODY

    form = page.forms.first
    @select = form.fields.first
    @option1 = @select.options.first
    @option2 = @select.options.last
  end

  def test_inspect
    assert_match "value: 2", @select.inspect
  end

  def test_value_missing_value
    option = node 'option'
    option.inner_html = 'blah'
    option = Mechanize::Form::Option.new option, nil

    assert_equal 'blah', option.value
  end

  def test_click
    @option1.click

    assert @option1.selected?
  end

  def test_select
    @option1.select

    assert @option1.selected?
  end

  def test_unselect
    @option2.unselect

    refute @option2.selected?
  end

  def test_selected_eh
    refute @option1.selected?
    assert @option2.selected?
  end

end

Version data entries

23 entries across 23 versions & 2 rubygems

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