celerity 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +14 -0
- data/Manifest.txt +127 -151
- data/README.txt +15 -20
- data/lib/celerity.rb +13 -5
- data/lib/celerity/browser.rb +296 -0
- data/lib/celerity/clickable_element.rb +1 -0
- data/lib/celerity/collections.rb +4 -0
- data/lib/celerity/container.rb +69 -2
- data/lib/celerity/disabled_element.rb +1 -0
- data/lib/celerity/element.rb +103 -38
- data/lib/celerity/element_collections.rb +14 -8
- data/lib/celerity/element_locator.rb +61 -50
- data/lib/celerity/element_map.rb +51 -0
- data/lib/celerity/elements/button.rb +1 -0
- data/lib/celerity/elements/file_field.rb +3 -2
- data/lib/celerity/elements/form.rb +1 -0
- data/lib/celerity/elements/frame.rb +16 -1
- data/lib/celerity/elements/image.rb +15 -13
- data/lib/celerity/elements/link.rb +4 -1
- data/lib/celerity/elements/option.rb +1 -0
- data/lib/celerity/elements/radio_check.rb +19 -7
- data/lib/celerity/elements/select_list.rb +17 -2
- data/lib/celerity/elements/table.rb +34 -20
- data/lib/celerity/elements/table_body.rb +2 -2
- data/lib/celerity/elements/table_cell.rb +3 -1
- data/lib/celerity/elements/table_footer.rb +2 -2
- data/lib/celerity/elements/table_header.rb +2 -2
- data/lib/celerity/elements/table_row.rb +4 -2
- data/lib/celerity/elements/text_field.rb +20 -9
- data/lib/celerity/exception.rb +11 -18
- data/lib/celerity/extra/method_generator.rb +13 -8
- data/lib/celerity/htmlunit/download.sh +23 -0
- data/lib/celerity/htmlunit/htmlunit-2.2.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-core-js-2.2.jar +0 -0
- data/lib/celerity/htmlunit/{nekohtml-1.9.7.jar → nekohtml-1.9.8.jar} +0 -0
- data/lib/celerity/input_element.rb +1 -1
- data/lib/celerity/version.rb +1 -1
- data/lib/celerity/watir_compatibility.rb +37 -23
- data/spec/area_spec.rb +19 -4
- data/spec/areas_spec.rb +2 -3
- data/spec/{ie_spec.rb → browser_spec.rb} +66 -15
- data/spec/button_spec.rb +36 -3
- data/spec/buttons_spec.rb +2 -3
- data/spec/checkbox_spec.rb +43 -8
- data/spec/checkboxes_spec.rb +2 -3
- data/spec/div_spec.rb +31 -4
- data/spec/divs_spec.rb +2 -3
- data/spec/element_spec.rb +36 -6
- data/spec/filefield_spec.rb +28 -13
- data/spec/filefields_spec.rb +2 -3
- data/spec/form_spec.rb +6 -3
- data/spec/forms_spec.rb +2 -3
- data/spec/frame_spec.rb +14 -5
- data/spec/frames_spec.rb +71 -0
- data/spec/hidden_spec.rb +21 -3
- data/spec/hiddens_spec.rb +2 -3
- data/spec/hn_spec.rb +30 -12
- data/spec/hns_spec.rb +14 -10
- data/spec/html/form_js_bug.html +11 -0
- data/spec/html/forms_with_input_elements.html +2 -1
- data/spec/html/invalid_js.html +11 -0
- data/spec/html/latin1_text.html +1 -0
- data/spec/html/non_control_elements.html +8 -4
- data/spec/html/simple_ajax.html +22 -0
- data/spec/htmlunit_spec.rb +4 -5
- data/spec/image_spec.rb +33 -3
- data/spec/images_spec.rb +2 -3
- data/spec/label_spec.rb +16 -3
- data/spec/labels_spec.rb +2 -3
- data/spec/li_spec.rb +25 -3
- data/spec/link_spec.rb +35 -3
- data/spec/links_spec.rb +2 -3
- data/spec/lis_spec.rb +2 -3
- data/spec/map_spec.rb +19 -3
- data/spec/maps_spec.rb +2 -3
- data/spec/meta_spec.rb +3 -1
- data/spec/ol_spec.rb +17 -3
- data/spec/ols_spec.rb +2 -3
- data/spec/option_spec.rb +28 -3
- data/spec/p_spec.rb +30 -2
- data/spec/pre_spec.rb +25 -3
- data/spec/pres_spec.rb +2 -3
- data/spec/ps_spec.rb +2 -3
- data/spec/radio_spec.rb +47 -3
- data/spec/radios_spec.rb +2 -3
- data/spec/select_list_spec.rb +42 -3
- data/spec/select_lists_spec.rb +2 -3
- data/spec/span_spec.rb +32 -7
- data/spec/spans_spec.rb +2 -4
- data/spec/spec_helper.rb +5 -25
- data/spec/table_bodies_spec.rb +7 -5
- data/spec/table_body_spec.rb +11 -4
- data/spec/table_cell_spec.rb +15 -4
- data/spec/table_cells_spec.rb +3 -4
- data/spec/table_footer_spec.rb +11 -4
- data/spec/table_footers_spec.rb +7 -5
- data/spec/table_header_spec.rb +11 -4
- data/spec/table_headers_spec.rb +7 -5
- data/spec/table_row_spec.rb +31 -7
- data/spec/table_rows_spec.rb +5 -4
- data/spec/table_spec.rb +36 -7
- data/spec/tables_spec.rb +2 -3
- data/spec/text_field_spec.rb +51 -13
- data/spec/text_fields_spec.rb +2 -3
- data/spec/ul_spec.rb +18 -3
- data/spec/uls_spec.rb +2 -3
- data/spec/{watir_compatability_spec.rb → watir_compatibility_spec.rb} +42 -35
- data/support/spec_server.rb +9 -0
- metadata +167 -161
- metadata.gz.sig +0 -0
- data/benchmark/bm_2000_spans.rb +0 -48
- data/benchmark/bm_digg.rb +0 -26
- data/benchmark/bm_google_images.rb +0 -36
- data/benchmark/bm_input_locator.rb +0 -69
- data/benchmark/loader.rb +0 -9
- data/config/hoe.rb +0 -68
- data/config/requirements.rb +0 -15
- data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/js-1.7R1.jar +0 -0
- data/lib/celerity/ie.rb +0 -195
- data/setup.rb +0 -1583
- data/support/celerity_viewer/rubycocoa/CelerityViewer.icns +0 -0
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/classes.nib +0 -37
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/info.nib +0 -19
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/keyedobjects.nib +0 -0
- data/support/celerity_viewer/rubycocoa/Info.plist.erb +0 -28
- data/support/celerity_viewer/rubycocoa/MainController.rb +0 -23
- data/support/celerity_viewer/rubycocoa/README +0 -94
- data/support/celerity_viewer/rubycocoa/Rakefile +0 -100
- data/support/celerity_viewer/rubycocoa/distributed_viewer.rb +0 -86
- data/support/celerity_viewer/rubycocoa/main.m +0 -7
- data/support/celerity_viewer/rubycocoa/main.rb +0 -27
- data/tasks/benchmark.rake +0 -4
- data/tasks/environment.rake +0 -7
- data/tasks/simple_ci.rake +0 -94
data/spec/p_spec.rb
CHANGED
@@ -3,8 +3,7 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
3
3
|
describe P do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@browser =
|
7
|
-
add_spec_checker(@browser)
|
6
|
+
@browser = Browser.new
|
8
7
|
end
|
9
8
|
|
10
9
|
before :each do
|
@@ -23,9 +22,11 @@ describe P do
|
|
23
22
|
@browser.p(:index, 1).should exist
|
24
23
|
@browser.p(:xpath, "//p[@id='lead']").should exist
|
25
24
|
end
|
25
|
+
|
26
26
|
it "should return true if the element exists (default how = :id)" do
|
27
27
|
@browser.p("lead").should exist
|
28
28
|
end
|
29
|
+
|
29
30
|
it "should return false if the 'p' doesn't exist" do
|
30
31
|
@browser.p(:id, "no_such_id").should_not exist
|
31
32
|
@browser.p(:id, /no_such_id/).should_not exist
|
@@ -36,9 +37,11 @@ describe P do
|
|
36
37
|
@browser.p(:index, 1337).should_not exist
|
37
38
|
@browser.p(:xpath, "//p[@id='no_such_id']").should_not exist
|
38
39
|
end
|
40
|
+
|
39
41
|
it "should raise ArgumentError when 'what' argument is invalid" do
|
40
42
|
lambda { @browser.p(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
41
43
|
end
|
44
|
+
|
42
45
|
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
43
46
|
lambda { @browser.p(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
44
47
|
end
|
@@ -49,9 +52,11 @@ describe P do
|
|
49
52
|
it "should return the class attribute" do
|
50
53
|
@browser.p(:index, 1).class_name.should == 'lead'
|
51
54
|
end
|
55
|
+
|
52
56
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
53
57
|
@browser.p(:index, 3).class_name.should == ''
|
54
58
|
end
|
59
|
+
|
55
60
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
56
61
|
lambda { @browser.p(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
|
57
62
|
end
|
@@ -61,9 +66,11 @@ describe P do
|
|
61
66
|
it "should return the id attribute" do
|
62
67
|
@browser.p(:index, 1).id.should == "lead"
|
63
68
|
end
|
69
|
+
|
64
70
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
65
71
|
@browser.p(:index, 3).id.should == ''
|
66
72
|
end
|
73
|
+
|
67
74
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
68
75
|
lambda { @browser.p(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
69
76
|
lambda { @browser.p(:index, 1337).id }.should raise_error(UnknownObjectException)
|
@@ -74,9 +81,11 @@ describe P do
|
|
74
81
|
it "should return the name attribute" do
|
75
82
|
@browser.p(:index, 2).name.should == "invalid_attribute"
|
76
83
|
end
|
84
|
+
|
77
85
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
78
86
|
@browser.p(:index, 3).name.should == ''
|
79
87
|
end
|
88
|
+
|
80
89
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
81
90
|
lambda { @browser.p(:id, "no_such_id").name }.should raise_error(UnknownObjectException)
|
82
91
|
lambda { @browser.p(:index, 1337).name }.should raise_error(UnknownObjectException)
|
@@ -87,9 +96,11 @@ describe P do
|
|
87
96
|
it "should return the title attribute" do
|
88
97
|
@browser.p(:index, 1).title.should == 'Lorem ipsum'
|
89
98
|
end
|
99
|
+
|
90
100
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
91
101
|
@browser.p(:index, 3).title.should == ''
|
92
102
|
end
|
103
|
+
|
93
104
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
94
105
|
lambda { @browser.p(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
|
95
106
|
lambda { @browser.p(:xpath, "//p[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
|
@@ -100,9 +111,11 @@ describe P do
|
|
100
111
|
it "should return the text of the p" do
|
101
112
|
@browser.p(:index, 2).text.should == 'Sed pretium metus et quam. Nullam odio dolor, vestibulum non, tempor ut, vehicula sed, sapien. Vestibulum placerat ligula at quam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.'
|
102
113
|
end
|
114
|
+
|
103
115
|
it "should return an empty string if the element doesn't contain any text" do
|
104
116
|
@browser.p(:index, 5).text.should == ''
|
105
117
|
end
|
118
|
+
|
106
119
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
107
120
|
lambda { @browser.p(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
|
108
121
|
lambda { @browser.p(:xpath , "//p[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
|
@@ -113,14 +126,28 @@ describe P do
|
|
113
126
|
it "should return the value attribute" do
|
114
127
|
@browser.p(:index, 2).value.should == "invalid_attribute"
|
115
128
|
end
|
129
|
+
|
116
130
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
117
131
|
@browser.p(:index, 3).value.should == ''
|
118
132
|
end
|
133
|
+
|
119
134
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
120
135
|
lambda { @browser.p(:id , "no_such_id").value }.should raise_error(UnknownObjectException)
|
121
136
|
lambda { @browser.p(:index , 1337).value }.should raise_error(UnknownObjectException)
|
122
137
|
end
|
123
138
|
end
|
139
|
+
|
140
|
+
describe "#respond_to?" do
|
141
|
+
it "should return true for all attribute methods" do
|
142
|
+
@browser.p(:index, 1).should respond_to(:class_name)
|
143
|
+
@browser.p(:index, 1).should respond_to(:id)
|
144
|
+
@browser.p(:index, 1).should respond_to(:name)
|
145
|
+
@browser.p(:index, 1).should respond_to(:title)
|
146
|
+
@browser.p(:index, 1).should respond_to(:text)
|
147
|
+
@browser.p(:index, 1).should respond_to(:value)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
124
151
|
|
125
152
|
# Other
|
126
153
|
describe "#to_s" do
|
@@ -131,6 +158,7 @@ describe P do
|
|
131
158
|
" title: Lorem ipsum\n" +
|
132
159
|
" text: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur eu pede. Ut justo. Praesent feugiat, elit in feugiat iaculis, sem risus rutrum justo, eget fermentum dolor arcu non nunc."
|
133
160
|
end
|
161
|
+
|
134
162
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
135
163
|
lambda { @browser.p(:xpath, "//p[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
|
136
164
|
end
|
data/spec/pre_spec.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe Pre do
|
3
|
+
describe "Pre" do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@browser =
|
7
|
-
add_spec_checker(@browser)
|
6
|
+
@browser = Browser.new
|
8
7
|
end
|
9
8
|
|
10
9
|
before :each do
|
@@ -23,9 +22,11 @@ describe Pre do
|
|
23
22
|
@browser.pre(:index, 1).should exist
|
24
23
|
@browser.pre(:xpath, "//pre[@id='rspec']").should exist
|
25
24
|
end
|
25
|
+
|
26
26
|
it "should return true if the element exists (default how = :id)" do
|
27
27
|
@browser.pre("rspec").should exist
|
28
28
|
end
|
29
|
+
|
29
30
|
it "should return false if the 'p' doesn't exist" do
|
30
31
|
@browser.pre(:id, "no_such_id").should_not exist
|
31
32
|
@browser.pre(:id, /no_such_id/).should_not exist
|
@@ -36,9 +37,11 @@ describe Pre do
|
|
36
37
|
@browser.pre(:index, 1337).should_not exist
|
37
38
|
@browser.pre(:xpath, "//pre[@id='no_such_id']").should_not exist
|
38
39
|
end
|
40
|
+
|
39
41
|
it "should raise ArgumentError when 'what' argument is invalid" do
|
40
42
|
lambda { @browser.pre(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
41
43
|
end
|
44
|
+
|
42
45
|
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
43
46
|
lambda { @browser.pre(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
44
47
|
end
|
@@ -49,9 +52,11 @@ describe Pre do
|
|
49
52
|
it "should return the class attribute" do
|
50
53
|
@browser.pre(:id, 'rspec').class_name.should == 'ruby'
|
51
54
|
end
|
55
|
+
|
52
56
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
53
57
|
@browser.pre(:index, 1).class_name.should == ''
|
54
58
|
end
|
59
|
+
|
55
60
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
56
61
|
lambda { @browser.pre(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
|
57
62
|
end
|
@@ -61,9 +66,11 @@ describe Pre do
|
|
61
66
|
it "should return the id attribute" do
|
62
67
|
@browser.pre(:class, 'ruby').id.should == "rspec"
|
63
68
|
end
|
69
|
+
|
64
70
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
65
71
|
@browser.pre(:index, 1).id.should == ''
|
66
72
|
end
|
73
|
+
|
67
74
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
68
75
|
lambda { @browser.pre(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
69
76
|
lambda { @browser.pre(:index, 1337).id }.should raise_error(UnknownObjectException)
|
@@ -74,9 +81,11 @@ describe Pre do
|
|
74
81
|
it "should return the title attribute" do
|
75
82
|
@browser.pre(:class, 'brainfuck').title.should == 'The brainfuck language is an esoteric programming language noted for its extreme minimalism'
|
76
83
|
end
|
84
|
+
|
77
85
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
78
86
|
@browser.pre(:index, 1).title.should == ''
|
79
87
|
end
|
88
|
+
|
80
89
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
81
90
|
lambda { @browser.pre(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
|
82
91
|
lambda { @browser.pre(:xpath, "//pre[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
|
@@ -87,20 +96,33 @@ describe Pre do
|
|
87
96
|
it "should return the text of the p" do
|
88
97
|
@browser.pre(:class, 'haskell').text.should == 'main = putStrLn "Hello World"'
|
89
98
|
end
|
99
|
+
|
90
100
|
it "should return an empty string if the element doesn't contain any text" do
|
91
101
|
@browser.pre(:index, 1).text.should == ''
|
92
102
|
end
|
103
|
+
|
93
104
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
94
105
|
lambda { @browser.pre(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
|
95
106
|
lambda { @browser.pre(:xpath , "//pre[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
|
96
107
|
end
|
97
108
|
end
|
109
|
+
|
110
|
+
describe "#respond_to?" do
|
111
|
+
it "should return true for all attribute methods" do
|
112
|
+
@browser.image(:index, 1).should respond_to(:class_name)
|
113
|
+
@browser.image(:index, 1).should respond_to(:id)
|
114
|
+
@browser.image(:index, 1).should respond_to(:title)
|
115
|
+
@browser.image(:index, 1).should respond_to(:text)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
98
119
|
|
99
120
|
# Other
|
100
121
|
describe "#to_s" do
|
101
122
|
it "should return a human readable representation of the element" do
|
102
123
|
@browser.pre(:index, 1).to_s.should == "tag: pre"
|
103
124
|
end
|
125
|
+
|
104
126
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
105
127
|
lambda { @browser.pre(:xpath, "//pre[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
|
106
128
|
end
|
data/spec/pres_spec.rb
CHANGED
data/spec/ps_spec.rb
CHANGED
data/spec/radio_spec.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe Radio do
|
3
|
+
describe "Radio" do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@browser =
|
7
|
-
add_spec_checker(@browser)
|
6
|
+
@browser = Browser.new
|
8
7
|
end
|
9
8
|
|
10
9
|
before :each do
|
@@ -28,13 +27,16 @@ describe Radio do
|
|
28
27
|
@browser.radio(:index, 1).should exist
|
29
28
|
@browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should exist
|
30
29
|
end
|
30
|
+
|
31
31
|
it "should return true if the element exists (default how = :name)" do
|
32
32
|
@browser.radio("new_user_newsletter").should exist
|
33
33
|
end
|
34
|
+
|
34
35
|
it "should return true if the radio button exists (search by name and value)" do
|
35
36
|
@browser.radio(:name, "new_user_newsletter", 'yes').should exist
|
36
37
|
@browser.radio(:xpath, "//input[@name='new_user_newsletter' and @value='yes']").set
|
37
38
|
end
|
39
|
+
|
38
40
|
it "should return false if the radio button does not exist" do
|
39
41
|
@browser.radio(:id, "no_such_id").should_not exist
|
40
42
|
@browser.radio(:id, /no_such_id/).should_not exist
|
@@ -49,19 +51,23 @@ describe Radio do
|
|
49
51
|
@browser.radio(:index, 1337).should_not exist
|
50
52
|
@browser.radio(:xpath, "input[@id='no_such_id']").should_not exist
|
51
53
|
end
|
54
|
+
|
52
55
|
it "should return false if the radio button does not exist (search by name and value)" do
|
53
56
|
@browser.radio(:name, "new_user_newsletter", 'no_such_value').should_not exist
|
54
57
|
@browser.radio(:xpath, "//input[@name='new_user_newsletter' and @value='no_such_value']").should_not exist
|
55
58
|
@browser.radio(:name, "no_such_name", 'yes').should_not exist
|
56
59
|
@browser.radio(:xpath, "//input[@name='no_such_name' and @value='yes']").should_not exist
|
57
60
|
end
|
61
|
+
|
58
62
|
it "should return true for radios with a string value" do
|
59
63
|
@browser.radio(:name, 'new_user_newsletter', 'yes').should exist
|
60
64
|
@browser.radio(:name, 'new_user_newsletter', 'no').should exist
|
61
65
|
end
|
66
|
+
|
62
67
|
it "should raise ArgumentError when 'what' argument is invalid" do
|
63
68
|
lambda { @browser.radio(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
64
69
|
end
|
70
|
+
|
65
71
|
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
66
72
|
lambda { @browser.radio(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
67
73
|
end
|
@@ -73,9 +79,11 @@ describe Radio do
|
|
73
79
|
it "should return the class name if the radio exists and has an attribute" do
|
74
80
|
@browser.radio(:id, "new_user_newsletter_yes").class_name.should == "huge"
|
75
81
|
end
|
82
|
+
|
76
83
|
it "should return an emptry string if the radio exists and the attribute doesn't" do
|
77
84
|
@browser.radio(:id, "new_user_newsletter_no").class_name.should == ""
|
78
85
|
end
|
86
|
+
|
79
87
|
it "should raise UnknownObjectException if the radio doesn't exist" do
|
80
88
|
lambda { @browser.radio(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
81
89
|
end
|
@@ -85,9 +93,11 @@ describe Radio do
|
|
85
93
|
it "should return the id attribute if the radio exists and has an attribute" do
|
86
94
|
@browser.radio(:index, 1).id.should == "new_user_newsletter_yes"
|
87
95
|
end
|
96
|
+
|
88
97
|
it "should return an emptry string if the radio exists and the attribute doesn't" do
|
89
98
|
@browser.radio(:index, 3).id.should == ""
|
90
99
|
end
|
100
|
+
|
91
101
|
it "should raise UnknownObjectException if the radio doesn't exist" do
|
92
102
|
lambda { @browser.radio(:index, 1337).id }.should raise_error(UnknownObjectException)
|
93
103
|
end
|
@@ -97,9 +107,11 @@ describe Radio do
|
|
97
107
|
it "should return the name attribute if the radio exists" do
|
98
108
|
@browser.radio(:id, 'new_user_newsletter_yes').name.should == "new_user_newsletter"
|
99
109
|
end
|
110
|
+
|
100
111
|
it "should return an empty string if the radio exists and the attribute doesn't" do
|
101
112
|
@browser.radio(:id, 'new_user_newsletter_absolutely').name.should == ""
|
102
113
|
end
|
114
|
+
|
103
115
|
it "should raise UnknownObjectException if the radio doesn't exist" do
|
104
116
|
lambda { @browser.radio(:index, 1337).name }.should raise_error(UnknownObjectException)
|
105
117
|
end
|
@@ -109,9 +121,11 @@ describe Radio do
|
|
109
121
|
it "should return the title attribute if the radio exists" do
|
110
122
|
@browser.radio(:id, "new_user_newsletter_no").title.should == "Traitor!"
|
111
123
|
end
|
124
|
+
|
112
125
|
it "should return an emptry string if the radio exists and the attribute doesn't" do
|
113
126
|
@browser.radio(:id, "new_user_newsletter_yes").title.should == ""
|
114
127
|
end
|
128
|
+
|
115
129
|
it "should raise UnknownObjectException if the radio doesn't exist" do
|
116
130
|
lambda { @browser.radio(:index, 1337).title }.should raise_error(UnknownObjectException)
|
117
131
|
end
|
@@ -121,6 +135,7 @@ describe Radio do
|
|
121
135
|
it "should return the type attribute if the radio exists" do
|
122
136
|
@browser.radio(:index, 1).type.should == "radio"
|
123
137
|
end
|
138
|
+
|
124
139
|
it "should raise UnknownObjectException if the radio doesn't exist" do
|
125
140
|
lambda { @browser.radio(:index, 1337).type }.should raise_error(UnknownObjectException)
|
126
141
|
end
|
@@ -130,11 +145,24 @@ describe Radio do
|
|
130
145
|
it "should return the value attribute if the radio exists" do
|
131
146
|
@browser.radio(:id, 'new_user_newsletter_yes').value.should == 'yes'
|
132
147
|
end
|
148
|
+
|
133
149
|
it "should raise UnknownObjectException if the radio doesn't exist" do
|
134
150
|
lambda { @browser.radio(:index, 1337).value}.should raise_error(UnknownObjectException)
|
135
151
|
end
|
136
152
|
end
|
137
153
|
|
154
|
+
describe "#respond_to?" do
|
155
|
+
it "should return true for all attribute methods" do
|
156
|
+
@browser.radio(:index, 1).should respond_to(:class_name)
|
157
|
+
@browser.radio(:index, 1).should respond_to(:id)
|
158
|
+
@browser.radio(:index, 1).should respond_to(:name)
|
159
|
+
@browser.radio(:index, 1).should respond_to(:title)
|
160
|
+
@browser.radio(:index, 1).should respond_to(:type)
|
161
|
+
@browser.radio(:index, 1).should respond_to(:value)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
|
138
166
|
|
139
167
|
# Access methods
|
140
168
|
describe "#enabled?" do
|
@@ -142,10 +170,12 @@ describe Radio do
|
|
142
170
|
@browser.radio(:id, "new_user_newsletter_yes").should be_enabled
|
143
171
|
@browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should be_enabled
|
144
172
|
end
|
173
|
+
|
145
174
|
it "should return false if the radio button is disabled" do
|
146
175
|
@browser.radio(:id, "new_user_newsletter_nah").should_not be_enabled
|
147
176
|
@browser.radio(:xpath,"//input[@id='new_user_newsletter_nah']").should_not be_enabled
|
148
177
|
end
|
178
|
+
|
149
179
|
it "should raise UnknownObjectException if the radio button doesn't exist" do
|
150
180
|
lambda { @browser.radio(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
|
151
181
|
lambda { @browser.radio(:xpath, "//input[@id='no_such_id']").enabled? }.should raise_error(UnknownObjectException)
|
@@ -156,9 +186,11 @@ describe Radio do
|
|
156
186
|
it "should return true if the radio is disabled" do
|
157
187
|
@browser.radio(:id, 'new_user_newsletter_nah').should be_disabled
|
158
188
|
end
|
189
|
+
|
159
190
|
it "should return false if the radio is enabled" do
|
160
191
|
@browser.radio(:id, 'new_user_newsletter_yes').should_not be_disabled
|
161
192
|
end
|
193
|
+
|
162
194
|
it "should raise UnknownObjectException if the radio doesn't exist" do
|
163
195
|
lambda { @browser.radio(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
|
164
196
|
end
|
@@ -171,14 +203,17 @@ describe Radio do
|
|
171
203
|
@browser.radio(:id, "new_user_newsletter_yes").clear
|
172
204
|
@browser.radio(:id, "new_user_newsletter_yes").should_not be_set
|
173
205
|
end
|
206
|
+
|
174
207
|
it "should clear the radio button when found by :xpath" do
|
175
208
|
@browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").clear
|
176
209
|
@browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should_not be_set
|
177
210
|
end
|
211
|
+
|
178
212
|
it "should raise UnknownObjectException if the radio button doesn't exist" do
|
179
213
|
lambda { @browser.radio(:name, "no_such_id").clear }.should raise_error(UnknownObjectException)
|
180
214
|
lambda { @browser.radio(:xpath, "//input[@id='no_such_id']").clear }.should raise_error(UnknownObjectException)
|
181
215
|
end
|
216
|
+
|
182
217
|
it "should raise ObjectDisabledException if the radio is disabled" do
|
183
218
|
@browser.radio(:id, "new_user_newsletter_nah").should_not be_set
|
184
219
|
lambda { @browser.radio(:id, "new_user_newsletter_nah").clear }.should raise_error(ObjectDisabledException)
|
@@ -191,10 +226,12 @@ describe Radio do
|
|
191
226
|
@browser.radio(:id, "new_user_newsletter_no").set
|
192
227
|
@browser.radio(:id, "new_user_newsletter_no").should be_set
|
193
228
|
end
|
229
|
+
|
194
230
|
it "should set the radio button when found by :xpath" do
|
195
231
|
@browser.radio(:xpath, "//input[@id='new_user_newsletter_no']").set
|
196
232
|
@browser.radio(:xpath, "//input[@id='new_user_newsletter_no']").should be_set
|
197
233
|
end
|
234
|
+
|
198
235
|
it "should fire the onclick event" do
|
199
236
|
@browser.div(:id, "wants_newsletter").text.should be_empty
|
200
237
|
@browser.radio(:id, "new_user_newsletter_no").set
|
@@ -202,10 +239,12 @@ describe Radio do
|
|
202
239
|
@browser.radio(:id, "new_user_newsletter_yes").set
|
203
240
|
@browser.div(:id, "wants_newsletter").text.should be_empty
|
204
241
|
end
|
242
|
+
|
205
243
|
it "should raise UnknownObjectException if the radio button doesn't exist" do
|
206
244
|
lambda { @browser.radio(:name, "no_such_name").set }.should raise_error(UnknownObjectException)
|
207
245
|
lambda { @browser.radio(:xpath, "//input[@name='no_such_name']").set }.should raise_error(UnknownObjectException)
|
208
246
|
end
|
247
|
+
|
209
248
|
it "should raise ObjectDisabledException if the radio is disabled" do
|
210
249
|
lambda { @browser.radio(:id, "new_user_newsletter_nah").set }.should raise_error(ObjectDisabledException)
|
211
250
|
lambda { @browser.radio(:xpath, "//input[@id='new_user_newsletter_nah']").set }.should raise_error(ObjectDisabledException )
|
@@ -218,9 +257,11 @@ describe Radio do
|
|
218
257
|
it "should return true if the radio button is set" do
|
219
258
|
@browser.radio(:id, "new_user_newsletter_yes").should be_set
|
220
259
|
end
|
260
|
+
|
221
261
|
it "should return false if the radio button unset" do
|
222
262
|
@browser.radio(:id, "new_user_newsletter_no").should_not be_set
|
223
263
|
end
|
264
|
+
|
224
265
|
it "should return the state for radios with string values" do
|
225
266
|
@browser.radio(:name, "new_user_newsletter", 'no').should_not be_set
|
226
267
|
@browser.radio(:name, "new_user_newsletter", 'no').set
|
@@ -228,6 +269,7 @@ describe Radio do
|
|
228
269
|
@browser.radio(:name, "new_user_newsletter", 'no').clear
|
229
270
|
@browser.radio(:name, "new_user_newsletter", 'no').should_not be_set
|
230
271
|
end
|
272
|
+
|
231
273
|
it "should raise UnknownObjectException if the radio button doesn't exist" do
|
232
274
|
lambda { @browser.radio(:id, "no_such_id").set? }.should raise_error(UnknownObjectException)
|
233
275
|
lambda { @browser.radio(:xpath, "//input[@id='no_such_id']").set? }.should raise_error(UnknownObjectException)
|
@@ -238,9 +280,11 @@ describe Radio do
|
|
238
280
|
it "should return true if the radio is set" do
|
239
281
|
@browser.radio(:id, "new_user_newsletter_yes").get_state.should be_true
|
240
282
|
end
|
283
|
+
|
241
284
|
it "should return false if the radio is unset" do
|
242
285
|
@browser.radio(:id, "new_user_newsletter_no").get_state.should be_false
|
243
286
|
end
|
287
|
+
|
244
288
|
it "should raise UnknownObjectException if the radio doesn't exist" do
|
245
289
|
lambda { @browser.radio(:name, "no_such_name").get_state }.should raise_error(UnknownObjectException)
|
246
290
|
lambda { @browser.radio(:xpath, "//input[@name='no_such_name']").get_state }.should raise_error(UnknownObjectException)
|