celerity 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/History.txt +10 -0
  2. data/README.txt +8 -11
  3. data/Rakefile +5 -3
  4. data/benchmark/bm_2000_spans.rb +48 -0
  5. data/benchmark/bm_digg.rb +26 -0
  6. data/benchmark/bm_google_images.rb +36 -0
  7. data/benchmark/bm_input_locator.rb +69 -0
  8. data/benchmark/loader.rb +9 -0
  9. data/lib/celerity.rb +3 -1
  10. data/lib/celerity/container.rb +23 -171
  11. data/lib/celerity/disabled_element.rb +1 -1
  12. data/lib/celerity/element.rb +78 -47
  13. data/lib/celerity/element_collections.rb +16 -32
  14. data/lib/celerity/element_locator.rb +135 -0
  15. data/lib/celerity/elements/button.rb +15 -0
  16. data/lib/celerity/elements/file_field.rb +1 -1
  17. data/lib/celerity/elements/form.rb +2 -1
  18. data/lib/celerity/elements/frame.rb +18 -21
  19. data/lib/celerity/elements/image.rb +2 -8
  20. data/lib/celerity/elements/label.rb +1 -3
  21. data/lib/celerity/elements/link.rb +1 -1
  22. data/lib/celerity/elements/option.rb +16 -0
  23. data/lib/celerity/elements/radio_check.rb +18 -7
  24. data/lib/celerity/elements/select_list.rb +1 -17
  25. data/lib/celerity/elements/table.rb +4 -4
  26. data/lib/celerity/elements/table_body.rb +6 -8
  27. data/lib/celerity/elements/table_cell.rb +3 -14
  28. data/lib/celerity/elements/table_row.rb +4 -10
  29. data/lib/celerity/elements/text_field.rb +16 -4
  30. data/lib/celerity/extra/method_generator.rb +144 -0
  31. data/lib/celerity/identifier.rb +10 -0
  32. data/lib/celerity/ie.rb +28 -13
  33. data/lib/celerity/input_element.rb +0 -4
  34. data/lib/celerity/non_control_elements.rb +12 -12
  35. data/lib/celerity/version.rb +1 -1
  36. data/spec/area_spec.rb +41 -41
  37. data/spec/areas_spec.rb +11 -11
  38. data/spec/button_spec.rb +73 -68
  39. data/spec/buttons_spec.rb +10 -10
  40. data/spec/checkbox_spec.rb +102 -96
  41. data/spec/checkboxes_spec.rb +10 -10
  42. data/spec/div_spec.rb +78 -73
  43. data/spec/divs_spec.rb +10 -10
  44. data/spec/element_spec.rb +20 -11
  45. data/spec/filefield_spec.rb +36 -41
  46. data/spec/filefields_spec.rb +10 -10
  47. data/spec/form_spec.rb +29 -29
  48. data/spec/forms_spec.rb +11 -11
  49. data/spec/frame_spec.rb +54 -49
  50. data/spec/hidden_spec.rb +43 -43
  51. data/spec/hiddens_spec.rb +10 -10
  52. data/spec/html/2000_spans.html +2009 -0
  53. data/spec/html/forms_with_input_elements.html +15 -9
  54. data/spec/html/non_control_elements.html +4 -2
  55. data/spec/ie_spec.rb +82 -48
  56. data/spec/image_spec.rb +83 -100
  57. data/spec/images_spec.rb +10 -10
  58. data/spec/label_spec.rb +29 -29
  59. data/spec/labels_spec.rb +10 -10
  60. data/spec/li_spec.rb +41 -41
  61. data/spec/link_spec.rb +65 -59
  62. data/spec/links_spec.rb +11 -11
  63. data/spec/lis_spec.rb +10 -10
  64. data/spec/map_spec.rb +30 -30
  65. data/spec/maps_spec.rb +10 -10
  66. data/spec/p_spec.rb +49 -49
  67. data/spec/pre_spec.rb +41 -41
  68. data/spec/pres_spec.rb +10 -10
  69. data/spec/ps_spec.rb +10 -10
  70. data/spec/radio_spec.rb +104 -97
  71. data/spec/radios_spec.rb +11 -11
  72. data/spec/select_list_spec.rb +118 -106
  73. data/spec/select_lists_spec.rb +15 -15
  74. data/spec/span_spec.rb +54 -54
  75. data/spec/spans_spec.rb +11 -11
  76. data/spec/spec.opts +1 -1
  77. data/spec/spec_helper.rb +23 -3
  78. data/spec/table_bodies.rb +8 -8
  79. data/spec/table_bodies_spec.rb +9 -9
  80. data/spec/table_body_spec.rb +28 -27
  81. data/spec/table_cell_spec.rb +25 -25
  82. data/spec/table_cells_spec.rb +16 -16
  83. data/spec/table_row_spec.rb +16 -16
  84. data/spec/table_rows_spec.rb +12 -12
  85. data/spec/table_spec.rb +36 -36
  86. data/spec/tables_spec.rb +12 -12
  87. data/spec/text_field_spec.rb +111 -92
  88. data/spec/text_fields_spec.rb +13 -13
  89. data/tasks/benchmark.rake +3 -0
  90. data/tasks/rspec.rake +2 -2
  91. data/tasks/testserver.rake +15 -0
  92. metadata +58 -46
  93. data/tasks/simple_ci.rake +0 -94
data/spec/pre_spec.rb CHANGED
@@ -3,108 +3,108 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
3
3
  describe "Pre" do
4
4
 
5
5
  before :all do
6
- @ie = IE.new
7
- add_spec_checker(@ie)
6
+ @browser = IE.new
7
+ add_spec_checker(@browser)
8
8
  end
9
9
 
10
10
  before :each do
11
- @ie.goto(TEST_HOST + "/non_control_elements.html")
11
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
12
12
  end
13
13
 
14
14
  # Exists method
15
15
  describe "#exist?" do
16
16
  it "should return true if the 'p' exists" do
17
- @ie.pre(:id, "rspec").should exist
18
- @ie.pre(:id, /rspec/).should exist
19
- @ie.pre(:text, '@ie.pre(:id, "rspec").should exist').should exist
20
- @ie.pre(:text, /@ie\.pre/).should exist
21
- @ie.pre(:class, "ruby").should exist
22
- @ie.pre(:class, /ruby/).should exist
23
- @ie.pre(:index, 1).should exist
24
- @ie.pre(:xpath, "//pre[@id='rspec']").should exist
17
+ @browser.pre(:id, "rspec").should exist
18
+ @browser.pre(:id, /rspec/).should exist
19
+ @browser.pre(:text, '@browser.pre(:id, "rspec").should exist').should exist
20
+ @browser.pre(:text, /@browser\.pre/).should exist
21
+ @browser.pre(:class, "ruby").should exist
22
+ @browser.pre(:class, /ruby/).should exist
23
+ @browser.pre(:index, 1).should exist
24
+ @browser.pre(:xpath, "//pre[@id='rspec']").should exist
25
25
  end
26
26
  it "should return false if the 'p' doesn't exist" do
27
- @ie.pre(:id, "no_such_id").should_not exist
28
- @ie.pre(:id, /no_such_id/).should_not exist
29
- @ie.pre(:text, "no_such_text").should_not exist
30
- @ie.pre(:text, /no_such_text/).should_not exist
31
- @ie.pre(:class, "no_such_class").should_not exist
32
- @ie.pre(:class, /no_such_class/).should_not exist
33
- @ie.pre(:index, 1337).should_not exist
34
- @ie.pre(:xpath, "//pre[@id='no_such_id']").should_not exist
27
+ @browser.pre(:id, "no_such_id").should_not exist
28
+ @browser.pre(:id, /no_such_id/).should_not exist
29
+ @browser.pre(:text, "no_such_text").should_not exist
30
+ @browser.pre(:text, /no_such_text/).should_not exist
31
+ @browser.pre(:class, "no_such_class").should_not exist
32
+ @browser.pre(:class, /no_such_class/).should_not exist
33
+ @browser.pre(:index, 1337).should_not exist
34
+ @browser.pre(:xpath, "//pre[@id='no_such_id']").should_not exist
35
35
  end
36
- it "should raise ArgumentError when what argument is invapred" do
37
- lambda { @ie.pre(:id, 3.14).exists? }.should raise_error(ArgumentError)
36
+ it "should raise ArgumentError when 'what' argument is invalid" do
37
+ lambda { @browser.pre(:id, 3.14).exists? }.should raise_error(ArgumentError)
38
38
  end
39
- it "should raise MissingWayOfFindingObjectException when how argument is invapred" do
40
- lambda { @ie.pre(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
39
+ it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
40
+ lambda { @browser.pre(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
41
41
  end
42
42
  end
43
43
 
44
44
  # Attribute methods
45
45
  describe "#class_name" do
46
46
  it "should return the class attribute" do
47
- @ie.pre(:id, 'rspec').class_name.should == 'ruby'
47
+ @browser.pre(:id, 'rspec').class_name.should == 'ruby'
48
48
  end
49
49
  it "should return an empty string if the element exists and the attribute doesn't" do
50
- @ie.pre(:index, 1).class_name.should == ''
50
+ @browser.pre(:index, 1).class_name.should == ''
51
51
  end
52
52
  it "should raise UnknownObjectException if the p doesn't exist" do
53
- lambda { @ie.pre(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
53
+ lambda { @browser.pre(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
54
54
  end
55
55
  end
56
56
 
57
57
  describe "#id" do
58
58
  it "should return the id attribute" do
59
- @ie.pre(:class, 'ruby').id.should == "rspec"
59
+ @browser.pre(:class, 'ruby').id.should == "rspec"
60
60
  end
61
61
  it "should return an empty string if the element exists and the attribute doesn't" do
62
- @ie.pre(:index, 1).id.should == ''
62
+ @browser.pre(:index, 1).id.should == ''
63
63
  end
64
64
  it "should raise UnknownObjectException if the p doesn't exist" do
65
- lambda { @ie.pre(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
66
- lambda { @ie.pre(:index, 1337).id }.should raise_error(UnknownObjectException)
65
+ lambda { @browser.pre(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
66
+ lambda { @browser.pre(:index, 1337).id }.should raise_error(UnknownObjectException)
67
67
  end
68
68
  end
69
69
 
70
70
  describe "#title" do
71
71
  it "should return the title attribute" do
72
- @ie.pre(:class, 'brainfuck').title.should == 'The brainfuck language is an esoteric programming language noted for its extreme minimalism'
72
+ @browser.pre(:class, 'brainfuck').title.should == 'The brainfuck language is an esoteric programming language noted for its extreme minimalism'
73
73
  end
74
74
  it "should return an empty string if the element exists and the attribute doesn't" do
75
- @ie.pre(:index, 1).title.should == ''
75
+ @browser.pre(:index, 1).title.should == ''
76
76
  end
77
77
  it "should raise UnknownObjectException if the p doesn't exist" do
78
- lambda { @ie.pre(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
79
- lambda { @ie.pre(:xpath, "//pre[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
78
+ lambda { @browser.pre(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
79
+ lambda { @browser.pre(:xpath, "//pre[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
80
80
  end
81
81
  end
82
82
 
83
83
  describe "#text" do
84
84
  it "should return the text of the p" do
85
- @ie.pre(:class, 'haskell').text.should == 'main = putStrLn "Hello World"'
85
+ @browser.pre(:class, 'haskell').text.should == 'main = putStrLn "Hello World"'
86
86
  end
87
87
  it "should return an empty string if the element doesn't contain any text" do
88
- @ie.pre(:index, 1).text.should == ''
88
+ @browser.pre(:index, 1).text.should == ''
89
89
  end
90
90
  it "should raise UnknownObjectException if the p doesn't exist" do
91
- lambda { @ie.pre(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
92
- lambda { @ie.pre(:xpath , "//pre[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
91
+ lambda { @browser.pre(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
92
+ lambda { @browser.pre(:xpath , "//pre[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
93
93
  end
94
94
  end
95
95
 
96
96
  # Other
97
97
  describe "#to_s" do
98
98
  it "should return a human readable representation of the element" do
99
- @ie.pre(:index, 1).to_s.should == "tag: pre"
99
+ @browser.pre(:index, 1).to_s.should == "tag: pre"
100
100
  end
101
101
  it "should raise UnknownObjectException if the p doesn't exist" do
102
- lambda { @ie.pre(:xpath, "//pre[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
102
+ lambda { @browser.pre(:xpath, "//pre[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
103
103
  end
104
104
  end
105
105
 
106
106
  after :all do
107
- @ie.close
107
+ @browser.close
108
108
  end
109
109
 
110
110
  end
data/spec/pres_spec.rb CHANGED
@@ -3,38 +3,38 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
3
3
  describe "Pres" do
4
4
 
5
5
  before :all do
6
- @ie = IE.new
7
- add_spec_checker(@ie)
6
+ @browser = IE.new
7
+ add_spec_checker(@browser)
8
8
  end
9
9
 
10
10
  before :each do
11
- @ie.goto(TEST_HOST + "/non_control_elements.html")
11
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
12
12
  end
13
13
 
14
14
  describe "#length" do
15
15
  it "should return the number of pres" do
16
- @ie.pres.length.should == 7
16
+ @browser.pres.length.should == 7
17
17
  end
18
18
  end
19
19
 
20
20
  describe "#[]" do
21
21
  it "should return the pre at the given index" do
22
- @ie.pres[2].id.should == "rspec"
22
+ @browser.pres[2].id.should == "rspec"
23
23
  end
24
24
  end
25
25
 
26
26
  describe "#each" do
27
27
  it "should iterate through pres correctly" do
28
- @ie.pres.each_with_index do |p, index|
29
- p.name.should == @ie.pre(:index, index+1).name
30
- p.id.should == @ie.pre(:index, index+1).id
31
- p.value.should == @ie.pre(:index, index+1).value
28
+ @browser.pres.each_with_index do |p, index|
29
+ p.name.should == @browser.pre(:index, index+1).name
30
+ p.id.should == @browser.pre(:index, index+1).id
31
+ p.value.should == @browser.pre(:index, index+1).value
32
32
  end
33
33
  end
34
34
  end
35
35
 
36
36
  after :all do
37
- @ie.close
37
+ @browser.close
38
38
  end
39
39
 
40
40
  end
data/spec/ps_spec.rb CHANGED
@@ -2,38 +2,38 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
3
  describe "Ps" do
4
4
  before :all do
5
- @ie = IE.new
6
- add_spec_checker(@ie)
5
+ @browser = IE.new
6
+ add_spec_checker(@browser)
7
7
  end
8
8
 
9
9
  before :each do
10
- @ie.goto(TEST_HOST + "/non_control_elements.html")
10
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
11
11
  end
12
12
 
13
13
  describe "#length" do
14
14
  it "should return the number of ps" do
15
- @ie.ps.length.should == 5
15
+ @browser.ps.length.should == 5
16
16
  end
17
17
  end
18
18
 
19
19
  describe "#[]" do
20
20
  it "should return the p at the given index" do
21
- @ie.ps[1].id.should == "lead"
21
+ @browser.ps[1].id.should == "lead"
22
22
  end
23
23
  end
24
24
 
25
25
  describe "#each" do
26
26
  it "should iterate through ps correctly" do
27
- @ie.ps.each_with_index do |p, index|
28
- p.name.should == @ie.p(:index, index+1).name
29
- p.id.should == @ie.p(:index, index+1).id
30
- p.value.should == @ie.p(:index, index+1).value
27
+ @browser.ps.each_with_index do |p, index|
28
+ p.name.should == @browser.p(:index, index+1).name
29
+ p.id.should == @browser.p(:index, index+1).id
30
+ p.value.should == @browser.p(:index, index+1).value
31
31
  end
32
32
  end
33
33
  end
34
34
 
35
35
  after :all do
36
- @ie.close
36
+ @browser.close
37
37
  end
38
38
 
39
39
  end
data/spec/radio_spec.rb CHANGED
@@ -3,12 +3,12 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
3
3
  describe "Radio" do
4
4
 
5
5
  before :all do
6
- @ie = IE.new
7
- add_spec_checker(@ie)
6
+ @browser = IE.new
7
+ add_spec_checker(@browser)
8
8
  end
9
9
 
10
10
  before :each do
11
- @ie.goto(TEST_HOST + "/forms_with_input_elements.html")
11
+ @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
12
12
  end
13
13
 
14
14
 
@@ -16,59 +16,60 @@ describe "Radio" do
16
16
 
17
17
  describe "#exists?" do
18
18
  it "should return true if the radio button exists" do
19
- @ie.radio(:id, "new_user_newsletter_yes").should exist
20
- @ie.radio(:id, /new_user_newsletter_yes/).should exist
21
- @ie.radio(:name, "new_user_newsletter").should exist
22
- @ie.radio(:name, /new_user_newsletter/).should exist
23
- @ie.radio(:value, "yes").should exist
24
- @ie.radio(:value, /yes/).should exist
25
- # we need to figure out what :text means for a radio button
26
- @ie.radio(:text, "yes").should exist
27
- @ie.radio(:text, /yes/).should exist
28
- @ie.radio(:class, "huge").should exist
29
- @ie.radio(:class, /huge/).should exist
30
- @ie.radio(:index, 1).should exist
31
- @ie.radio(:xpath, "input[@id='new_user_newsletter_yes']").should exist
19
+ @browser.radio(:id, "new_user_newsletter_yes").should exist
20
+ @browser.radio(:id, /new_user_newsletter_yes/).should exist
21
+ @browser.radio(:name, "new_user_newsletter").should exist
22
+ @browser.radio(:name, /new_user_newsletter/).should exist
23
+ @browser.radio(:value, "yes").should exist
24
+ @browser.radio(:value, /yes/).should exist
25
+ # TODO: figure out what :text means for a radio button
26
+ # @browser.radio(:text, "yes").should exist
27
+ # @browser.radio(:text, /yes/).should exist
28
+
29
+ @browser.radio(:class, "huge").should exist
30
+ @browser.radio(:class, /huge/).should exist
31
+ @browser.radio(:index, 1).should exist
32
+ @browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should exist
32
33
  end
33
34
 
34
35
  it "should return true if the radio button exists (search by name and value)" do
35
- @ie.radio(:name, "new_user_newsletter", 'yes').should exist
36
- @ie.radio(:xpath, "//input[@name='new_user_newsletter' and @value='yes']").set
36
+ @browser.radio(:name, "new_user_newsletter", 'yes').should exist
37
+ @browser.radio(:xpath, "//input[@name='new_user_newsletter' and @value='yes']").set
37
38
  end
38
39
 
39
40
  it "should return false if the radio button does not exist" do
40
- @ie.radio(:id, "no_such_id").should_not exist
41
- @ie.radio(:id, /no_such_id/).should_not exist
42
- @ie.radio(:name, "no_such_name").should_not exist
43
- @ie.radio(:name, /no_such_name/).should_not exist
44
- @ie.radio(:value, "no_such_value").should_not exist
45
- @ie.radio(:value, /no_such_value/).should_not exist
46
- @ie.radio(:text, "no_such_text").should_not exist
47
- @ie.radio(:text, /no_such_text/).should_not exist
48
- @ie.radio(:class, "no_such_class").should_not exist
49
- @ie.radio(:class, /no_such_class/).should_not exist
50
- @ie.radio(:index, 1337).should_not exist
51
- @ie.radio(:xpath, "input[@id='no_such_id']").should_not exist
41
+ @browser.radio(:id, "no_such_id").should_not exist
42
+ @browser.radio(:id, /no_such_id/).should_not exist
43
+ @browser.radio(:name, "no_such_name").should_not exist
44
+ @browser.radio(:name, /no_such_name/).should_not exist
45
+ @browser.radio(:value, "no_such_value").should_not exist
46
+ @browser.radio(:value, /no_such_value/).should_not exist
47
+ @browser.radio(:text, "no_such_text").should_not exist
48
+ @browser.radio(:text, /no_such_text/).should_not exist
49
+ @browser.radio(:class, "no_such_class").should_not exist
50
+ @browser.radio(:class, /no_such_class/).should_not exist
51
+ @browser.radio(:index, 1337).should_not exist
52
+ @browser.radio(:xpath, "input[@id='no_such_id']").should_not exist
52
53
  end
53
54
 
54
55
  it "should return false if the radio button does not exist (search by name and value)" do
55
- @ie.radio(:name, "new_user_newsletter", 'no_such_value').should_not exist
56
- @ie.radio(:xpath, "//input[@name='new_user_newsletter' and @value='no_such_value']").should_not exist
57
- @ie.radio(:name, "no_such_name", 'yes').should_not exist
58
- @ie.radio(:xpath, "//input[@name='no_such_name' and @value='yes']").should_not exist
56
+ @browser.radio(:name, "new_user_newsletter", 'no_such_value').should_not exist
57
+ @browser.radio(:xpath, "//input[@name='new_user_newsletter' and @value='no_such_value']").should_not exist
58
+ @browser.radio(:name, "no_such_name", 'yes').should_not exist
59
+ @browser.radio(:xpath, "//input[@name='no_such_name' and @value='yes']").should_not exist
59
60
  end
60
61
 
61
62
  it "should return true for radios with a string value" do
62
- @ie.radio(:name, 'new_user_newsletter', 'yes').should exist
63
- @ie.radio(:name, 'new_user_newsletter', 'no').should exist
63
+ @browser.radio(:name, 'new_user_newsletter', 'yes').should exist
64
+ @browser.radio(:name, 'new_user_newsletter', 'no').should exist
64
65
  end
65
66
 
66
- it "should raise ArgumentError when what argument is invalid" do
67
- lambda { @ie.radio(:id, 3.14).exists? }.should raise_error(ArgumentError)
67
+ it "should raise ArgumentError when 'what' argument is invalid" do
68
+ lambda { @browser.radio(:id, 3.14).exists? }.should raise_error(ArgumentError)
68
69
  end
69
70
 
70
- it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
71
- lambda { @ie.radio(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
71
+ it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
72
+ lambda { @browser.radio(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
72
73
  end
73
74
  end
74
75
 
@@ -77,67 +78,67 @@ describe "Radio" do
77
78
 
78
79
  describe "#class_name" do
79
80
  it "should return the class name if the radio exists and has an attribute" do
80
- @ie.radio(:id, "new_user_newsletter_yes").class_name.should == "huge"
81
+ @browser.radio(:id, "new_user_newsletter_yes").class_name.should == "huge"
81
82
  end
82
83
  it "should return an emptry string if the radio exists and the attribute doesn't" do
83
- @ie.radio(:id, "new_user_newsletter_no").class_name.should == ""
84
+ @browser.radio(:id, "new_user_newsletter_no").class_name.should == ""
84
85
  end
85
86
  it "should raise UnknownObjectException if the radio doesn't exist" do
86
- lambda { @ie.radio(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
87
+ lambda { @browser.radio(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
87
88
  end
88
89
  end
89
90
 
90
91
  describe "#id" do
91
92
  it "should return the id attribute if the radio exists and has an attribute" do
92
- @ie.radio(:index, 1).id.should == "new_user_newsletter_yes"
93
+ @browser.radio(:index, 1).id.should == "new_user_newsletter_yes"
93
94
  end
94
95
  it "should return an emptry string if the radio exists and the attribute doesn't" do
95
- @ie.radio(:index, 3).id.should == ""
96
+ @browser.radio(:index, 3).id.should == ""
96
97
  end
97
98
  it "should raise UnknownObjectException if the radio doesn't exist" do
98
- lambda { @ie.radio(:index, 1337).id }.should raise_error(UnknownObjectException)
99
+ lambda { @browser.radio(:index, 1337).id }.should raise_error(UnknownObjectException)
99
100
  end
100
101
  end
101
102
 
102
103
  describe "#name" do
103
104
  it "should return the name attribute if the radio exists" do
104
- @ie.radio(:id, 'new_user_newsletter_yes').name.should == "new_user_newsletter"
105
+ @browser.radio(:id, 'new_user_newsletter_yes').name.should == "new_user_newsletter"
105
106
  end
106
107
  it "should return an empty string if the radio exists and the attribute doesn't" do
107
- @ie.radio(:id, 'new_user_newsletter_absolutely').name.should == ""
108
+ @browser.radio(:id, 'new_user_newsletter_absolutely').name.should == ""
108
109
  end
109
110
  it "should raise UnknownObjectException if the radio doesn't exist" do
110
- lambda { @ie.radio(:index, 1337).name }.should raise_error(UnknownObjectException)
111
+ lambda { @browser.radio(:index, 1337).name }.should raise_error(UnknownObjectException)
111
112
  end
112
113
  end
113
114
 
114
115
  describe "#title" do
115
116
  it "should return the title attribute if the radio exists" do
116
- @ie.radio(:id, "new_user_newsletter_no").title.should == "Traitor!"
117
+ @browser.radio(:id, "new_user_newsletter_no").title.should == "Traitor!"
117
118
  end
118
119
  it "should return an emptry string if the radio exists and the attribute doesn't" do
119
- @ie.radio(:id, "new_user_newsletter_yes").title.should == ""
120
+ @browser.radio(:id, "new_user_newsletter_yes").title.should == ""
120
121
  end
121
122
  it "should raise UnknownObjectException if the radio doesn't exist" do
122
- lambda { @ie.radio(:index, 1337).title }.should raise_error(UnknownObjectException)
123
+ lambda { @browser.radio(:index, 1337).title }.should raise_error(UnknownObjectException)
123
124
  end
124
125
  end
125
126
 
126
127
  describe "#type" do
127
128
  it "should return the type attribute if the radio exists" do
128
- @ie.radio(:index, 1).type.should == "radio"
129
+ @browser.radio(:index, 1).type.should == "radio"
129
130
  end
130
131
  it "should raise UnknownObjectException if the radio doesn't exist" do
131
- lambda { @ie.radio(:index, 1337).type }.should raise_error(UnknownObjectException)
132
+ lambda { @browser.radio(:index, 1337).type }.should raise_error(UnknownObjectException)
132
133
  end
133
134
  end
134
135
 
135
136
  describe "#value" do
136
137
  it "should return the value attribute if the radio exists" do
137
- @ie.radio(:id, 'new_user_newsletter_yes').value.should == 'yes'
138
+ @browser.radio(:id, 'new_user_newsletter_yes').value.should == 'yes'
138
139
  end
139
140
  it "should raise UnknownObjectException if the radio doesn't exist" do
140
- lambda { @ie.radio(:index, 1337).value}.should raise_error(UnknownObjectException)
141
+ lambda { @browser.radio(:index, 1337).value}.should raise_error(UnknownObjectException)
141
142
  end
142
143
  end
143
144
 
@@ -146,28 +147,28 @@ describe "Radio" do
146
147
 
147
148
  describe "#enabled?" do
148
149
  it "should return true if the radio button is enabled" do
149
- @ie.radio(:id, "new_user_newsletter_yes").should be_enabled
150
- @ie.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should be_enabled
150
+ @browser.radio(:id, "new_user_newsletter_yes").should be_enabled
151
+ @browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should be_enabled
151
152
  end
152
153
  it "should return false if the radio button is disabled" do
153
- @ie.radio(:id, "new_user_newsletter_nah").should_not be_enabled
154
- @ie.radio(:xpath,"//input[@id='new_user_newsletter_nah']").should_not be_enabled
154
+ @browser.radio(:id, "new_user_newsletter_nah").should_not be_enabled
155
+ @browser.radio(:xpath,"//input[@id='new_user_newsletter_nah']").should_not be_enabled
155
156
  end
156
157
  it "should raise UnknownObjectException if the radio button doesn't exist" do
157
- lambda { @ie.radio(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
158
- lambda { @ie.radio(:xpath, "//input[@id='no_such_id']").enabled? }.should raise_error(UnknownObjectException)
158
+ lambda { @browser.radio(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
159
+ lambda { @browser.radio(:xpath, "//input[@id='no_such_id']").enabled? }.should raise_error(UnknownObjectException)
159
160
  end
160
161
  end
161
162
 
162
163
  describe "#disabled?" do
163
164
  it "should return true if the radio is disabled" do
164
- @ie.radio(:id, 'new_user_newsletter_nah').should be_disabled
165
+ @browser.radio(:id, 'new_user_newsletter_nah').should be_disabled
165
166
  end
166
167
  it "should return false if the radio is enabled" do
167
- @ie.radio(:id, 'new_user_newsletter_yes').should_not be_disabled
168
+ @browser.radio(:id, 'new_user_newsletter_yes').should_not be_disabled
168
169
  end
169
170
  it "should raise UnknownObjectException if the radio doesn't exist" do
170
- lambda { @ie.radio(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
171
+ lambda { @browser.radio(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
171
172
  end
172
173
  end
173
174
 
@@ -176,43 +177,49 @@ describe "Radio" do
176
177
 
177
178
  describe "clear" do
178
179
  it "should clear the radio button if it is set" do
179
- @ie.radio(:id, "new_user_newsletter_yes").clear
180
- @ie.radio(:id, "new_user_newsletter_yes").should_not be_set
180
+ @browser.radio(:id, "new_user_newsletter_yes").clear
181
+ @browser.radio(:id, "new_user_newsletter_yes").should_not be_set
181
182
  end
182
183
  it "should clear the radio button when found by :xpath" do
183
- @ie.radio(:xpath, "//input[@id='new_user_newsletter_yes']").clear
184
- @ie.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should_not be_set
184
+ @browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").clear
185
+ @browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should_not be_set
185
186
  end
186
187
  it "should raise UnknownObjectException if the radio button doesn't exist" do
187
- lambda { @ie.radio(:name, "no_such_id").clear }.should raise_error(UnknownObjectException)
188
- lambda { @ie.radio(:xpath, "//input[@id='no_such_id']").clear }.should raise_error(UnknownObjectException)
188
+ lambda { @browser.radio(:name, "no_such_id").clear }.should raise_error(UnknownObjectException)
189
+ lambda { @browser.radio(:xpath, "//input[@id='no_such_id']").clear }.should raise_error(UnknownObjectException)
189
190
  end
190
191
  it "should raise ObjectDisabledException if the radio is disabled" do
191
- @ie.radio(:id, "new_user_newsletter_nah").should_not be_set
192
- lambda { @ie.radio(:id, "new_user_newsletter_nah").clear }.should raise_error(ObjectDisabledException)
193
- lambda { @ie.radio(:xpath, "//input[@id='new_user_newsletter_nah']").clear }.should raise_error(ObjectDisabledException)
192
+ @browser.radio(:id, "new_user_newsletter_nah").should_not be_set
193
+ lambda { @browser.radio(:id, "new_user_newsletter_nah").clear }.should raise_error(ObjectDisabledException)
194
+ lambda { @browser.radio(:xpath, "//input[@id='new_user_newsletter_nah']").clear }.should raise_error(ObjectDisabledException)
194
195
  end
195
196
  end
196
197
 
197
198
  describe "#set" do
198
199
  it "should set the radio button" do
199
- @ie.radio(:id, "new_user_newsletter_no").set
200
- @ie.radio(:id, "new_user_newsletter_no").should be_set
200
+ @browser.radio(:id, "new_user_newsletter_no").set
201
+ @browser.radio(:id, "new_user_newsletter_no").should be_set
201
202
  end
202
203
  it "should set the radio button when found by :xpath" do
203
- @ie.radio(:xpath, "//input[@id='new_user_newsletter_no']").set
204
- @ie.radio(:xpath, "//input[@id='new_user_newsletter_no']").should be_set
204
+ @browser.radio(:xpath, "//input[@id='new_user_newsletter_no']").set
205
+ @browser.radio(:xpath, "//input[@id='new_user_newsletter_no']").should be_set
205
206
  end
206
207
 
207
- it "should fire the onclick event"
208
+ it "should fire the onclick event" do
209
+ @browser.div(:id, "wants_newsletter").text.should be_empty
210
+ @browser.radio(:id, "new_user_newsletter_no").set
211
+ @browser.div(:id, "wants_newsletter").text.should == @browser.radio(:id, "new_user_newsletter_no").title
212
+ @browser.radio(:id, "new_user_newsletter_yes").set
213
+ @browser.div(:id, "wants_newsletter").text.should be_empty
214
+ end
208
215
 
209
216
  it "should raise UnknownObjectException if the radio button doesn't exist" do
210
- lambda { @ie.radio(:name, "no_such_name").set }.should raise_error(UnknownObjectException)
211
- lambda { @ie.radio(:xpath, "//input[@name='no_such_name']").set }.should raise_error(UnknownObjectException)
217
+ lambda { @browser.radio(:name, "no_such_name").set }.should raise_error(UnknownObjectException)
218
+ lambda { @browser.radio(:xpath, "//input[@name='no_such_name']").set }.should raise_error(UnknownObjectException)
212
219
  end
213
220
  it "should raise ObjectDisabledException if the radio is disabled" do
214
- lambda { @ie.radio(:id, "new_user_newsletter_nah").set }.should raise_error(ObjectDisabledException)
215
- lambda { @ie.radio(:xpath, "//input[@id='new_user_newsletter_nah']").set }.should raise_error(ObjectDisabledException )
221
+ lambda { @browser.radio(:id, "new_user_newsletter_nah").set }.should raise_error(ObjectDisabledException)
222
+ lambda { @browser.radio(:xpath, "//input[@id='new_user_newsletter_nah']").set }.should raise_error(ObjectDisabledException )
216
223
  end
217
224
  end
218
225
 
@@ -221,39 +228,39 @@ describe "Radio" do
221
228
 
222
229
  describe '#set?' do
223
230
  it "should return true if the radio button is set" do
224
- @ie.radio(:id, "new_user_newsletter_yes").should be_set
231
+ @browser.radio(:id, "new_user_newsletter_yes").should be_set
225
232
  end
226
233
  it "should return false if the radio button unset" do
227
- @ie.radio(:id, "new_user_newsletter_no").should_not be_set
234
+ @browser.radio(:id, "new_user_newsletter_no").should_not be_set
228
235
  end
229
236
  it "should return the state for radios with string values" do
230
- @ie.radio(:name, "new_user_newsletter", 'no').should_not be_set
231
- @ie.radio(:name, "new_user_newsletter", 'no').set
232
- @ie.radio(:name, "new_user_newsletter", 'no').should be_set
233
- @ie.radio(:name, "new_user_newsletter", 'no').clear
234
- @ie.radio(:name, "new_user_newsletter", 'no').should_not be_set
237
+ @browser.radio(:name, "new_user_newsletter", 'no').should_not be_set
238
+ @browser.radio(:name, "new_user_newsletter", 'no').set
239
+ @browser.radio(:name, "new_user_newsletter", 'no').should be_set
240
+ @browser.radio(:name, "new_user_newsletter", 'no').clear
241
+ @browser.radio(:name, "new_user_newsletter", 'no').should_not be_set
235
242
  end
236
243
  it "should raise UnknownObjectException if the radio button doesn't exist" do
237
- lambda { @ie.radio(:id, "no_such_id").set? }.should raise_error(UnknownObjectException)
238
- lambda { @ie.radio(:xpath, "//input[@id='no_such_id']").set? }.should raise_error(UnknownObjectException)
244
+ lambda { @browser.radio(:id, "no_such_id").set? }.should raise_error(UnknownObjectException)
245
+ lambda { @browser.radio(:xpath, "//input[@id='no_such_id']").set? }.should raise_error(UnknownObjectException)
239
246
  end
240
247
  end
241
248
 
242
249
  describe "#get_state" do
243
250
  it "should return true if the radio is set" do
244
- @ie.radio(:id, "new_user_newsletter_yes").get_state.should be_true
251
+ @browser.radio(:id, "new_user_newsletter_yes").get_state.should be_true
245
252
  end
246
253
  it "should return false if the radio is unset" do
247
- @ie.radio(:id, "new_user_newsletter_no").get_state.should be_false
254
+ @browser.radio(:id, "new_user_newsletter_no").get_state.should be_false
248
255
  end
249
256
  it "should raise UnknownObjectException if the radio doesn't exist" do
250
- lambda { @ie.radio(:name, "no_such_name").get_state }.should raise_error(UnknownObjectException)
251
- lambda { @ie.radio(:xpath, "//input[@name='no_such_name']").get_state }.should raise_error(UnknownObjectException)
257
+ lambda { @browser.radio(:name, "no_such_name").get_state }.should raise_error(UnknownObjectException)
258
+ lambda { @browser.radio(:xpath, "//input[@name='no_such_name']").get_state }.should raise_error(UnknownObjectException)
252
259
  end
253
260
  end
254
261
 
255
262
  after :all do
256
- @ie.close
263
+ @browser.close
257
264
  end
258
265
 
259
266
  end