Sha256: 9042bb7cb310ec81858965734a532bf360d3b0cd18b26ce0c159c54a47300c7c

Contents?: true

Size: 987 Bytes

Versions: 18

Compression:

Stored size: 987 Bytes

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_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

18 entries across 18 versions & 4 rubygems

Version Path
mechanize-2.5.1 test/test_mechanize_form_option.rb
mechanize-2.5 test/test_mechanize_form_option.rb
mechanize-2.4 test/test_mechanize_form_option.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/mechanize-2.3/test/test_mechanize_form_option.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/mechanize-2.3/test/test_mechanize_form_option.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/mechanize-2.3/test/test_mechanize_form_option.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/mechanize-2.3/test/test_mechanize_form_option.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/mechanize-2.3/test/test_mechanize_form_option.rb
mechanize-2.3 test/test_mechanize_form_option.rb
mechanize-2.2.1 test/test_mechanize_form_option.rb
mechanize-2.2 test/test_mechanize_form_option.rb
mechanize-2.1.1 test/test_mechanize_form_option.rb
domo-0.0.5 vendor/bundle/ruby/1.9.1/gems/mechanize-2.1/test/test_mechanize_form_option.rb
diamond-mechanize-2.4 test/test_mechanize_form_option.rb
diamond-mechanize-2.3 test/test_mechanize_form_option.rb
diamond-mechanize-2.1 test/test_mechanize_form_option.rb
mechanize-2.1 test/test_mechanize_form_option.rb
mechanize-2.1.pre.1 test/test_mechanize_form_option.rb