celerity 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +10 -0
- data/README.txt +8 -11
- data/Rakefile +5 -3
- data/benchmark/bm_2000_spans.rb +48 -0
- data/benchmark/bm_digg.rb +26 -0
- data/benchmark/bm_google_images.rb +36 -0
- data/benchmark/bm_input_locator.rb +69 -0
- data/benchmark/loader.rb +9 -0
- data/lib/celerity.rb +3 -1
- data/lib/celerity/container.rb +23 -171
- data/lib/celerity/disabled_element.rb +1 -1
- data/lib/celerity/element.rb +78 -47
- data/lib/celerity/element_collections.rb +16 -32
- data/lib/celerity/element_locator.rb +135 -0
- data/lib/celerity/elements/button.rb +15 -0
- data/lib/celerity/elements/file_field.rb +1 -1
- data/lib/celerity/elements/form.rb +2 -1
- data/lib/celerity/elements/frame.rb +18 -21
- data/lib/celerity/elements/image.rb +2 -8
- data/lib/celerity/elements/label.rb +1 -3
- data/lib/celerity/elements/link.rb +1 -1
- data/lib/celerity/elements/option.rb +16 -0
- data/lib/celerity/elements/radio_check.rb +18 -7
- data/lib/celerity/elements/select_list.rb +1 -17
- data/lib/celerity/elements/table.rb +4 -4
- data/lib/celerity/elements/table_body.rb +6 -8
- data/lib/celerity/elements/table_cell.rb +3 -14
- data/lib/celerity/elements/table_row.rb +4 -10
- data/lib/celerity/elements/text_field.rb +16 -4
- data/lib/celerity/extra/method_generator.rb +144 -0
- data/lib/celerity/identifier.rb +10 -0
- data/lib/celerity/ie.rb +28 -13
- data/lib/celerity/input_element.rb +0 -4
- data/lib/celerity/non_control_elements.rb +12 -12
- data/lib/celerity/version.rb +1 -1
- data/spec/area_spec.rb +41 -41
- data/spec/areas_spec.rb +11 -11
- data/spec/button_spec.rb +73 -68
- data/spec/buttons_spec.rb +10 -10
- data/spec/checkbox_spec.rb +102 -96
- data/spec/checkboxes_spec.rb +10 -10
- data/spec/div_spec.rb +78 -73
- data/spec/divs_spec.rb +10 -10
- data/spec/element_spec.rb +20 -11
- data/spec/filefield_spec.rb +36 -41
- data/spec/filefields_spec.rb +10 -10
- data/spec/form_spec.rb +29 -29
- data/spec/forms_spec.rb +11 -11
- data/spec/frame_spec.rb +54 -49
- data/spec/hidden_spec.rb +43 -43
- data/spec/hiddens_spec.rb +10 -10
- data/spec/html/2000_spans.html +2009 -0
- data/spec/html/forms_with_input_elements.html +15 -9
- data/spec/html/non_control_elements.html +4 -2
- data/spec/ie_spec.rb +82 -48
- data/spec/image_spec.rb +83 -100
- data/spec/images_spec.rb +10 -10
- data/spec/label_spec.rb +29 -29
- data/spec/labels_spec.rb +10 -10
- data/spec/li_spec.rb +41 -41
- data/spec/link_spec.rb +65 -59
- data/spec/links_spec.rb +11 -11
- data/spec/lis_spec.rb +10 -10
- data/spec/map_spec.rb +30 -30
- data/spec/maps_spec.rb +10 -10
- data/spec/p_spec.rb +49 -49
- data/spec/pre_spec.rb +41 -41
- data/spec/pres_spec.rb +10 -10
- data/spec/ps_spec.rb +10 -10
- data/spec/radio_spec.rb +104 -97
- data/spec/radios_spec.rb +11 -11
- data/spec/select_list_spec.rb +118 -106
- data/spec/select_lists_spec.rb +15 -15
- data/spec/span_spec.rb +54 -54
- data/spec/spans_spec.rb +11 -11
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +23 -3
- data/spec/table_bodies.rb +8 -8
- data/spec/table_bodies_spec.rb +9 -9
- data/spec/table_body_spec.rb +28 -27
- data/spec/table_cell_spec.rb +25 -25
- data/spec/table_cells_spec.rb +16 -16
- data/spec/table_row_spec.rb +16 -16
- data/spec/table_rows_spec.rb +12 -12
- data/spec/table_spec.rb +36 -36
- data/spec/tables_spec.rb +12 -12
- data/spec/text_field_spec.rb +111 -92
- data/spec/text_fields_spec.rb +13 -13
- data/tasks/benchmark.rake +3 -0
- data/tasks/rspec.rake +2 -2
- data/tasks/testserver.rake +15 -0
- metadata +58 -46
- data/tasks/simple_ci.rake +0 -94
data/spec/div_spec.rb
CHANGED
@@ -2,140 +2,144 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe "Div" do
|
4
4
|
before :all do
|
5
|
-
@
|
6
|
-
add_spec_checker(@
|
5
|
+
@browser = IE.new
|
6
|
+
add_spec_checker(@browser)
|
7
7
|
end
|
8
8
|
|
9
9
|
before :each do
|
10
|
-
@
|
10
|
+
@browser.goto(TEST_HOST + "/non_control_elements.html")
|
11
11
|
end
|
12
12
|
|
13
13
|
|
14
14
|
# Exists method
|
15
15
|
describe "#exists?" do
|
16
16
|
it "should return true if the element exists" do
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
17
|
+
@browser.div(:id, "header").should exist
|
18
|
+
@browser.div(:id, /header/).should exist
|
19
|
+
@browser.div(:title, "Header and primary navigation").should exist
|
20
|
+
@browser.div(:title, /Header and primary navigation/).should exist
|
21
|
+
@browser.div(:text, "This is a footer.").should exist
|
22
|
+
@browser.div(:text, /This is a footer\./).should exist
|
23
|
+
@browser.div(:class, "profile").should exist
|
24
|
+
@browser.div(:class, /profile/).should exist
|
25
|
+
@browser.div(:index, 1).should exist
|
26
|
+
@browser.div(:xpath, "//div[@id='header']").should exist
|
27
27
|
end
|
28
28
|
it "should return false if the element does not exist" do
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
34
|
-
@
|
35
|
-
@
|
36
|
-
@
|
37
|
-
@
|
38
|
-
@
|
29
|
+
@browser.div(:id, "no_such_id").should_not exist
|
30
|
+
@browser.div(:id, /no_such_id/).should_not exist
|
31
|
+
@browser.div(:title, "no_such_title").should_not exist
|
32
|
+
@browser.div(:title, /no_such_title/).should_not exist
|
33
|
+
@browser.div(:text, "no_such_text").should_not exist
|
34
|
+
@browser.div(:text, /no_such_text/).should_not exist
|
35
|
+
@browser.div(:class, "no_such_class").should_not exist
|
36
|
+
@browser.div(:class, /no_such_class/).should_not exist
|
37
|
+
@browser.div(:index, 1337).should_not exist
|
38
|
+
@browser.div(:xpath, "//div[@id='no_such_id']").should_not exist
|
39
39
|
end
|
40
|
-
it "should raise ArgumentError when what argument is invalid" do
|
41
|
-
lambda { @
|
40
|
+
it "should raise ArgumentError when 'what' argument is invalid" do
|
41
|
+
lambda { @browser.div(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
42
42
|
end
|
43
|
-
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
44
|
-
lambda { @
|
43
|
+
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
44
|
+
lambda { @browser.div(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
# Attribute methods
|
49
49
|
describe "#class_name" do
|
50
50
|
it "should return the class attribute if the element exists" do
|
51
|
-
@
|
51
|
+
@browser.div(:id , "footer").class_name.should == "profile"
|
52
52
|
end
|
53
53
|
it "should return an empty string if the element exists but the attribute doesn't" do
|
54
|
-
@
|
54
|
+
@browser.div(:id , "content").class_name.should == ""
|
55
55
|
end
|
56
56
|
it "should raise UnknownObjectException if the element does not exist" do
|
57
|
-
lambda { @
|
58
|
-
lambda { @
|
59
|
-
lambda { @
|
60
|
-
lambda { @
|
57
|
+
lambda { @browser.div(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
58
|
+
lambda { @browser.div(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
|
59
|
+
lambda { @browser.div(:index, 1337).class_name }.should raise_error(UnknownObjectException)
|
60
|
+
lambda { @browser.div(:xpath, "//div[@id='no_such_id']").class_name }.should raise_error(UnknownObjectException)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
describe "#id" do
|
65
65
|
it "should return the id attribute if the element exists" do
|
66
|
-
@
|
66
|
+
@browser.div(:index, 2).id.should == "outer_container"
|
67
67
|
end
|
68
68
|
it "should return an empty string if the element exists, but the attribute doesn't" do
|
69
|
-
@
|
69
|
+
@browser.div(:index, 1).id.should == ""
|
70
70
|
end
|
71
71
|
it "should raise UnknownObjectException if the element does not exist" do
|
72
|
-
lambda {@
|
73
|
-
lambda {@
|
74
|
-
lambda {@
|
72
|
+
lambda {@browser.div(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
73
|
+
lambda {@browser.div(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
|
74
|
+
lambda {@browser.div(:index, 1337).id }.should raise_error(UnknownObjectException)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
describe "#name" do
|
79
79
|
it "should return the name attribute if the element exists" do
|
80
|
-
@
|
80
|
+
@browser.div(:id, 'promo').name.should == "invalid_attribute"
|
81
81
|
end
|
82
82
|
it "should return an empty string if the element exists but the attribute doesn't" do
|
83
|
-
@
|
83
|
+
@browser.div(:index, 1).name.should == ""
|
84
84
|
end
|
85
85
|
it "should raise UnknownObjectException if the element does not exist" do
|
86
|
-
lambda {@
|
87
|
-
lambda {@
|
88
|
-
lambda {@
|
86
|
+
lambda {@browser.div(:id, "div77").name }.should raise_error(UnknownObjectException)
|
87
|
+
lambda {@browser.div(:title, "div77").name }.should raise_error(UnknownObjectException)
|
88
|
+
lambda {@browser.div(:index, 44).name }.should raise_error(UnknownObjectException)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
describe "#text" do
|
93
93
|
it "should return the text of the div" do
|
94
|
-
@
|
95
|
-
@
|
96
|
-
@
|
94
|
+
@browser.div(:id, "footer").text.strip.should == "This is a footer."
|
95
|
+
@browser.div(:title, "Closing remarks").text.strip.should == "This is a footer."
|
96
|
+
@browser.div(:xpath, "//div[@id='footer']").text.strip.should == "This is a footer."
|
97
97
|
end
|
98
98
|
it "should return an empty string if the element exists but contains no text" do
|
99
|
-
@
|
99
|
+
@browser.div(:index, 1).text.strip.should == ""
|
100
100
|
end
|
101
101
|
it "should raise UnknownObjectException if the element does not exist" do
|
102
|
-
lambda { @
|
103
|
-
lambda { @
|
104
|
-
lambda { @
|
105
|
-
lambda { @
|
102
|
+
lambda { @browser.div(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
|
103
|
+
lambda { @browser.div(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
|
104
|
+
lambda { @browser.div(:index, 1337).text }.should raise_error(UnknownObjectException)
|
105
|
+
lambda { @browser.div(:xpath, "//div[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
109
|
describe "#value" do
|
110
110
|
it "should return the value attribute if the element exists" do
|
111
|
-
@
|
111
|
+
@browser.div(:id, 'promo').value.should == "invalid_attribute"
|
112
112
|
end
|
113
113
|
it "should return an empty string if the element exists but the attribute doesn't" do
|
114
|
-
@
|
114
|
+
@browser.div(:index, 1).value.should == ""
|
115
115
|
end
|
116
116
|
it "should raise UnknownObjectException if the element does not exist" do
|
117
|
-
lambda {@
|
118
|
-
lambda {@
|
119
|
-
lambda {@
|
117
|
+
lambda {@browser.div(:id, "no_such_id").value }.should raise_error(UnknownObjectException)
|
118
|
+
lambda {@browser.div(:title, "no_such_title").value }.should raise_error(UnknownObjectException)
|
119
|
+
lambda {@browser.div(:index, 1337).value }.should raise_error(UnknownObjectException)
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
123
|
# Manipulation methods
|
124
124
|
describe "#click" do
|
125
|
-
it "should fire events when clicked"
|
125
|
+
it "should fire events when clicked" do
|
126
|
+
@browser.div(:id, 'best_language').text.should_not == 'Ruby!'
|
127
|
+
@browser.div(:id, 'best_language').click
|
128
|
+
@browser.div(:id, 'best_language').text.should == 'Ruby!'
|
129
|
+
end
|
126
130
|
it "should raise UnknownObjectException if the element does not exist" do
|
127
|
-
lambda { @
|
128
|
-
lambda { @
|
129
|
-
lambda { @
|
130
|
-
lambda { @
|
131
|
+
lambda { @browser.div(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
|
132
|
+
lambda { @browser.div(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
|
133
|
+
lambda { @browser.div(:index, 1337).click }.should raise_error(UnknownObjectException)
|
134
|
+
lambda { @browser.div(:xpath, "//div[@id='no_such_id']").click }.should raise_error(UnknownObjectException)
|
131
135
|
end
|
132
136
|
end
|
133
137
|
|
134
138
|
describe "#html" do
|
135
139
|
it "should return the HTML of the element" do
|
136
|
-
html = @
|
140
|
+
html = @browser.div(:id, 'footer').html
|
137
141
|
html.should include('<div id="footer" title="Closing remarks" class="profile">')
|
138
|
-
html.should include('
|
142
|
+
html.should include('This is a footer.')
|
139
143
|
html.should_not include('<div id="content">')
|
140
144
|
html.should_not include('</body>')
|
141
145
|
end
|
@@ -143,31 +147,32 @@ describe "Div" do
|
|
143
147
|
|
144
148
|
describe "#to_s" do
|
145
149
|
it "should return a human readable representation of the element" do
|
146
|
-
@
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
150
|
+
@browser.div(:id, 'footer').to_s.should ==
|
151
|
+
%q{tag: div
|
152
|
+
id: footer
|
153
|
+
title: Closing remarks
|
154
|
+
class: profile
|
155
|
+
text: This is a footer.}
|
151
156
|
end
|
152
157
|
end
|
153
158
|
|
154
159
|
# Divs can't be disabled
|
155
160
|
# describe "#disabled?" do
|
156
161
|
# it "should raise UnknownObjectException if the element does not exist" do
|
157
|
-
# lambda {@
|
158
|
-
# lambda {@
|
159
|
-
# lambda {@
|
162
|
+
# lambda {@browser.div(:id , "div77").disabled? }.should raise_error(UnknownObjectException)
|
163
|
+
# lambda {@browser.div(:title , "div77").disabled? }.should raise_error(UnknownObjectException)
|
164
|
+
# lambda {@browser.div(:index , 44).disabled? }.should raise_error(UnknownObjectException)
|
160
165
|
# end
|
161
166
|
#
|
162
167
|
# it "should return false if the element is enabled" do
|
163
|
-
# @
|
168
|
+
# @browser.div(:index , 2).should_not be_disabled
|
164
169
|
# end
|
165
170
|
#
|
166
171
|
# it "should return true if the element is disabled"
|
167
172
|
# end
|
168
173
|
|
169
174
|
after :all do
|
170
|
-
@
|
175
|
+
@browser.close
|
171
176
|
end
|
172
177
|
|
173
178
|
end
|
data/spec/divs_spec.rb
CHANGED
@@ -2,38 +2,38 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe "Divs" do
|
4
4
|
before :all do
|
5
|
-
@
|
6
|
-
add_spec_checker(@
|
5
|
+
@browser = IE.new
|
6
|
+
add_spec_checker(@browser)
|
7
7
|
end
|
8
8
|
|
9
9
|
before :each do
|
10
|
-
@
|
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 divs" do
|
15
|
-
@
|
15
|
+
@browser.divs.length.should == 7
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#[]" do
|
20
20
|
it "should return the div at the given index" do
|
21
|
-
@
|
21
|
+
@browser.divs[2].id.should == "outer_container"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "#each" do
|
26
26
|
it "should iterate through divs correctly" do
|
27
|
-
@
|
28
|
-
d.name.should == @
|
29
|
-
d.id.should == @
|
30
|
-
d.class_name.should == @
|
27
|
+
@browser.divs.each_with_index do |d, index|
|
28
|
+
d.name.should == @browser.div(:index, index+1).name
|
29
|
+
d.id.should == @browser.div(:index, index+1).id
|
30
|
+
d.class_name.should == @browser.div(:index, index+1).class_name
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
after :all do
|
36
|
-
@
|
36
|
+
@browser.close
|
37
37
|
end
|
38
38
|
|
39
39
|
end
|
data/spec/element_spec.rb
CHANGED
@@ -3,27 +3,36 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
3
3
|
describe "Element" do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@
|
7
|
-
add_spec_checker(@
|
6
|
+
@browser = IE.new
|
7
|
+
add_spec_checker(@browser)
|
8
8
|
end
|
9
9
|
|
10
10
|
before :each do
|
11
|
-
@
|
11
|
+
@browser.goto(TEST_HOST + "/forms_with_input_elements.html")
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
|
+
describe "#new" do
|
15
|
+
it "should find elements matching the conditions when given a hash of :how => 'what' arguments" do
|
16
|
+
@browser.checkbox(:name => 'new_user_interests', :title => 'Dancing is fun!').value.should == 'dancing'
|
17
|
+
@browser.text_field(:class_name => 'name', :index => 2).id.should == 'new_user_last_name'
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should raise UnknownObjectException with a sane error message when given a hash of :how => 'what' arguments" do
|
21
|
+
conditions = {:index => 100, :name => "foo"}
|
22
|
+
lambda { @browser.text_field(conditions).id }.should raise_error(UnknownObjectException, /Unable to locate object, using (\{:name=>"foo", :index=>100\}|\{:index=>100, :name=>"foo"\})/)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
14
26
|
describe "#method_missing" do
|
15
27
|
it "should magically return the requested attribute if the attribute is defined in the attribute list" do
|
16
|
-
@
|
17
|
-
end
|
18
|
-
it "should call the super class method if the attribute is not defined in the element's attribute list" do
|
19
|
-
@ie.form(:index, 2).text.should == 'Username Username 1 Delete'
|
28
|
+
@browser.form(:index, 1).action.should == 'post_to_me'
|
20
29
|
end
|
21
|
-
it "should raise NoMethodError if the requested method
|
22
|
-
lambda { @
|
30
|
+
it "should raise NoMethodError if the requested method isn't among the attributes" do
|
31
|
+
lambda { @browser.button(:index, 1).no_such_attribute_or_method }.should raise_error(NoMethodError)
|
23
32
|
end
|
24
33
|
end
|
25
34
|
|
26
35
|
after :all do
|
27
|
-
@
|
36
|
+
@browser.close
|
28
37
|
end
|
29
38
|
end
|
data/spec/filefield_spec.rb
CHANGED
@@ -2,91 +2,87 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe "FileField" do
|
4
4
|
before :all do
|
5
|
-
@
|
6
|
-
add_spec_checker(@
|
5
|
+
@browser = IE.new
|
6
|
+
add_spec_checker(@browser)
|
7
7
|
end
|
8
8
|
|
9
9
|
before :each do
|
10
|
-
@
|
10
|
+
@browser.goto(TEST_HOST + "/forms_with_input_elements.html")
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
# Exist method
|
15
|
-
|
16
13
|
describe "#exist?" do
|
17
14
|
it "should return true if the file field exists" do
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@
|
15
|
+
@browser.file_field(:id, 'new_user_portrait').should exist
|
16
|
+
@browser.file_field(:id, /new_user_portrait/).should exist
|
17
|
+
@browser.file_field(:name, 'new_user_portrait').should exist
|
18
|
+
@browser.file_field(:name, /new_user_portrait/).should exist
|
19
|
+
@browser.file_field(:class, 'portrait').should exist
|
20
|
+
@browser.file_field(:class, /portrait/).should exist
|
21
|
+
@browser.file_field(:index, 1).should exist
|
22
|
+
@browser.file_field(:xpath, "//input[@id='new_user_portrait']").should exist
|
26
23
|
end
|
27
24
|
|
28
25
|
it "should return false if the file field doesn't exist" do
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
34
|
-
@
|
35
|
-
@
|
36
|
-
@
|
26
|
+
@browser.file_field(:id, 'no_such_id').should_not exist
|
27
|
+
@browser.file_field(:id, /no_such_id/).should_not exist
|
28
|
+
@browser.file_field(:name, 'no_such_name').should_not exist
|
29
|
+
@browser.file_field(:name, /no_such_name/).should_not exist
|
30
|
+
@browser.file_field(:class, 'no_such_class').should_not exist
|
31
|
+
@browser.file_field(:class, /no_such_class/).should_not exist
|
32
|
+
@browser.file_field(:index, 1337).should_not exist
|
33
|
+
@browser.file_field(:xpath, "//input[@id='no_such_id']").should_not exist
|
37
34
|
end
|
38
35
|
|
39
|
-
it "should raise ArgumentError when what argument is invalid" do
|
40
|
-
lambda { @
|
36
|
+
it "should raise ArgumentError when 'what' argument is invalid" do
|
37
|
+
lambda { @browser.file_field(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
41
38
|
end
|
42
39
|
|
43
|
-
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
44
|
-
lambda { @
|
40
|
+
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
41
|
+
lambda { @browser.file_field(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
45
42
|
end
|
46
43
|
end
|
47
44
|
|
48
|
-
|
49
45
|
# Attribute methods
|
50
46
|
|
51
47
|
describe "#class_name" do
|
52
48
|
it "should return the class attribute if the text field exists" do
|
53
|
-
@
|
49
|
+
@browser.file_field(:index, 1).class_name.should == "portrait"
|
54
50
|
end
|
55
51
|
it "should raise UnknownObjectException if the text field doesn't exist" do
|
56
|
-
lambda { @
|
52
|
+
lambda { @browser.file_field(:index, 1337).class_name }.should raise_error(UnknownObjectException)
|
57
53
|
end
|
58
54
|
end
|
59
55
|
|
60
56
|
describe "#id" do
|
61
57
|
it "should return the id attribute if the text field exists" do
|
62
|
-
@
|
58
|
+
@browser.file_field(:index, 1).id.should == "new_user_portrait"
|
63
59
|
end
|
64
60
|
it "should raise UnknownObjectException if the text field doesn't exist" do
|
65
|
-
lambda { @
|
61
|
+
lambda { @browser.file_field(:index, 1337).id }.should raise_error(UnknownObjectException)
|
66
62
|
end
|
67
63
|
end
|
68
64
|
|
69
65
|
describe "#name" do
|
70
66
|
it "should return the name attribute if the text field exists" do
|
71
|
-
@
|
67
|
+
@browser.file_field(:index, 1).name.should == "new_user_portrait"
|
72
68
|
end
|
73
69
|
it "should raise UnknownObjectException if the text field doesn't exist" do
|
74
|
-
lambda { @
|
70
|
+
lambda { @browser.file_field(:index, 1337).name }.should raise_error(UnknownObjectException)
|
75
71
|
end
|
76
72
|
end
|
77
73
|
|
78
74
|
describe "#title" do
|
79
75
|
it "should return the title attribute if the text field exists" do
|
80
|
-
@
|
76
|
+
@browser.file_field(:id, "new_user_portrait").title.should == "Smile!"
|
81
77
|
end
|
82
78
|
end
|
83
79
|
|
84
80
|
describe "#type" do
|
85
81
|
it "should return the type attribute if the text field exists" do
|
86
|
-
@
|
82
|
+
@browser.file_field(:index, 1).type.should == "file"
|
87
83
|
end
|
88
84
|
it "should raise UnknownObjectException if the text field doesn't exist" do
|
89
|
-
lambda { @
|
85
|
+
lambda { @browser.file_field(:index, 1337).type }.should raise_error(UnknownObjectException)
|
90
86
|
end
|
91
87
|
end
|
92
88
|
|
@@ -95,15 +91,14 @@ describe "FileField" do
|
|
95
91
|
|
96
92
|
describe "#set" do
|
97
93
|
it "should be able to set a file path in the field and click the upload button" do
|
98
|
-
@
|
99
|
-
@
|
100
|
-
|
101
|
-
pending
|
94
|
+
@browser.file_field(:name, "new_user_portrait").set(__FILE__)
|
95
|
+
@browser.file_field(:name, "new_user_portrait").value.should == __FILE__
|
96
|
+
@browser.button(:name, "new_user_submit").click
|
102
97
|
end
|
103
98
|
end
|
104
99
|
|
105
100
|
after :all do
|
106
|
-
@
|
101
|
+
@browser.close
|
107
102
|
end
|
108
103
|
|
109
104
|
end
|