Permalink
Browse files

fix tests

  • Loading branch information...
1 parent 198cb42 commit b0b54a09a13429a82569654571c0ab89c1926bfa @jarmo jarmo committed Mar 12, 2012
Showing with 15 additions and 15 deletions.
  1. +1 −1 commonwatir/unittests/select_list_test.rb
  2. +1 −1 watir/lib/watir/input_elements.rb
  3. +13 −13 watir/unittests/selectbox_test.rb
View
2 commonwatir/unittests/select_list_test.rb
@@ -11,7 +11,7 @@ def setup
def test_select_by_numeric
# make sure we still find the right option if passed a number
browser.select_list(:id, 'year').select(2011)
- assert_equal(['2011'], browser.select_list(:id, 'year').selected_options)
+ assert_equal(['2011'], browser.select_list(:id, 'year').selected_options.map(&:text))
end
end
View
2 watir/lib/watir/input_elements.rb
@@ -78,7 +78,7 @@ def matching_items_in_select_list(attribute, value)
if value.is_a?(Regexp)
opt.send(attribute) =~ value
elsif value.is_a?(String) || value.is_a?(Numeric)
- opt.send(attribute) == value
+ opt.send(attribute) == value.to_s
else
raise TypeError, "#{value.inspect} can be only String, Regexp or Numeric!"
end
View
26 watir/unittests/selectbox_test.rb
@@ -29,9 +29,9 @@ def test_class_name
end
def test_select_by_text
- assert_equal('Option 3', browser.select_list(:name, "sel1").getSelectedItems.first.text)
+ assert_equal('Option 3', browser.select_list(:name, "sel1").selected_options.first.text)
browser.select_list(:name, "sel1").select('Option 2')
- assert_equal('Option 2', browser.select_list(:name, "sel1").getSelectedItems.first.text)
+ assert_equal('Option 2', browser.select_list(:name, "sel1").selected_options.first.text)
end
def test_select_by_value
@@ -47,12 +47,12 @@ def test_Option_text_select
assert_raises(MissingWayOfFindingObjectException) { browser.select_list(:name, "sel1").option(:missing, "Option 1").select }
browser.select_list(:name, "sel1").option(:text, "Option 1").select
- assert_equal("Option 1", browser.select_list(:name, "sel1").getSelectedItems.first.text)
+ assert_equal("Option 1", browser.select_list(:name, "sel1").selected_options.first.text)
end
def test_clear_selection
- assert_raises(TypeError) { browser.select_list(:name, "sel1").clearSelection }
- assert_nothing_thrown { browser.select_list(:name, "sel2").clearSelection }
+ assert_raises(TypeError) { browser.select_list(:name, "sel1").clear }
+ assert_nothing_thrown { browser.select_list(:name, "sel2").clear }
end
def xtest_option_class_name
@@ -66,10 +66,10 @@ def xtest_option_class_name
tag_method :test_includes, :fails_on_firefox
def test_includes
- assert browser.select_list(:name, 'sel1').includes?('Option 1')
- assert browser.select_list(:name, 'sel1').includes?(/option/i)
- assert ! browser.select_list(:name, 'sel1').includes?('Option 6')
- assert ! browser.select_list(:name, 'sel1').includes?(/foobar/)
+ assert browser.select_list(:name, 'sel1').include?('Option 1')
+ assert browser.select_list(:name, 'sel1').include?(/option/i)
+ assert ! browser.select_list(:name, 'sel1').include?('Option 6')
+ assert ! browser.select_list(:name, 'sel1').include?(/foobar/)
end
# SelectList#selected?
@@ -94,7 +94,7 @@ def test_properties
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).value }
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).name }
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).id }
- assert_raises(UnknownObjectException) { browser.select_list(:index, 199).disabled }
+ assert_raises(UnknownObjectException) { browser.select_list(:index, 199).disabled? }
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).type }
assert_equal("o3" , browser.select_list(:index, 0).value)
@@ -106,9 +106,9 @@ def test_properties
browser.select_list(:index,0).select(/1/)
assert_equal("o1", browser.select_list(:index, 0).value)
- assert_false( browser.select_list(:index, 0).disabled)
- assert(browser.select_list(:index, 3).disabled)
- assert(browser.select_list(:id, 'selectbox_4').disabled)
+ assert_false( browser.select_list(:index, 0).disabled?)
+ assert(browser.select_list(:index, 3).disabled?)
+ assert(browser.select_list(:id, 'selectbox_4').disabled?)
end
def test_iterator

0 comments on commit b0b54a0

Please sign in to comment.