operawatir 0.4.3.pre1-jruby → 0.5-jruby

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/.gitmodules +1 -1
  2. data/CHANGES +230 -0
  3. data/Gemfile +4 -0
  4. data/Rakefile +3 -2
  5. data/VERSION +1 -1
  6. data/bin/desktopwatir +1 -1
  7. data/bin/operawatir +16 -4
  8. data/lib/operadriver/guava-r09.jar +0 -0
  9. data/lib/operadriver/operadriver-v0.7.2.jar +0 -0
  10. data/lib/operadriver/selenium-nodeps-20100909.jar +0 -0
  11. data/lib/operawatir.rb +10 -3
  12. data/lib/operawatir/actions.rb +111 -0
  13. data/lib/operawatir/browser.rb +24 -20
  14. data/lib/operawatir/clickable_item.rb +68 -0
  15. data/lib/operawatir/compat.rb +4 -4
  16. data/lib/operawatir/compat/collection.rb +1 -1
  17. data/lib/operawatir/compat/element.rb +1 -1
  18. data/lib/operawatir/compat/window.rb +4 -3
  19. data/lib/operawatir/desktop_browser.rb +299 -95
  20. data/lib/operawatir/desktop_common.rb +88 -23
  21. data/lib/operawatir/desktop_container.rb +103 -34
  22. data/lib/operawatir/desktop_enums.rb +4 -4
  23. data/lib/operawatir/desktop_exceptions.rb +2 -2
  24. data/lib/operawatir/desktop_helper.rb +31 -8
  25. data/lib/operawatir/element.rb +6 -2
  26. data/lib/operawatir/exceptions.rb +4 -4
  27. data/lib/operawatir/helper.rb +6 -6
  28. data/lib/operawatir/keys.rb +4 -4
  29. data/lib/operawatir/preferences.rb +126 -155
  30. data/lib/operawatir/quickwidgets.rb +3 -3
  31. data/lib/operawatir/quickwidgets/quick_addressfield.rb +12 -5
  32. data/lib/operawatir/quickwidgets/quick_button.rb +39 -53
  33. data/lib/operawatir/quickwidgets/quick_checkbox.rb +6 -6
  34. data/lib/operawatir/quickwidgets/quick_dialogtab.rb +5 -5
  35. data/lib/operawatir/quickwidgets/quick_dropdown.rb +28 -4
  36. data/lib/operawatir/quickwidgets/quick_dropdownitem.rb +46 -0
  37. data/lib/operawatir/quickwidgets/quick_editfield.rb +16 -13
  38. data/lib/operawatir/quickwidgets/quick_label.rb +1 -1
  39. data/lib/operawatir/quickwidgets/quick_menu.rb +155 -0
  40. data/lib/operawatir/quickwidgets/quick_menuitem.rb +387 -0
  41. data/lib/operawatir/quickwidgets/quick_searchfield.rb +7 -4
  42. data/lib/operawatir/quickwidgets/quick_tab.rb +23 -12
  43. data/lib/operawatir/quickwidgets/quick_thumbnail.rb +4 -4
  44. data/lib/operawatir/quickwidgets/quick_toolbar.rb +1 -1
  45. data/lib/operawatir/quickwidgets/quick_treeitem.rb +45 -29
  46. data/lib/operawatir/quickwidgets/quick_treeview.rb +2 -2
  47. data/lib/operawatir/quickwidgets/quick_widget.rb +267 -77
  48. data/lib/operawatir/quickwidgets/quick_window.rb +64 -38
  49. data/lib/operawatir/screenshot.rb +1 -1
  50. data/lib/operawatir/utils.rb +31 -0
  51. data/lib/operawatir/window.rb +1 -1
  52. data/operawatir.gemspec +38 -132
  53. data/spec/operawatir/core/actions_spec.rb +202 -0
  54. data/spec/operawatir/core/browser_spec.rb +8 -8
  55. data/spec/operawatir/core/element_spec.rb +11 -2
  56. data/spec/operawatir/core/keys_spec.rb +50 -2
  57. data/spec/operawatir/core/preferences_spec.rb +44 -128
  58. data/spec/operawatir/core/spatnav_spec.rb +16 -16
  59. data/spec/operawatir/core/utils_spec.rb +47 -0
  60. data/spec/operawatir/core/window_spec.rb +1 -1
  61. data/spec/operawatir/desktop/desktopbrowser_spec.rb +191 -22
  62. data/spec/operawatir/desktop/quickbutton_spec.rb +197 -164
  63. data/spec/operawatir/desktop/quickcheckbox_spec.rb +12 -12
  64. data/spec/operawatir/desktop/quickdialogtab_spec.rb +11 -11
  65. data/spec/operawatir/desktop/quickdropdown_spec.rb +25 -25
  66. data/spec/operawatir/desktop/quickeditfield_spec.rb +31 -31
  67. data/spec/operawatir/desktop/quickmenu_spec.rb +57 -0
  68. data/spec/operawatir/desktop/quickmenuitem_spec.rb +168 -0
  69. data/spec/operawatir/desktop/quicktab_spec.rb +26 -15
  70. data/spec/operawatir/desktop/quickthumbnail_spec.rb +18 -4
  71. data/spec/operawatir/desktop/quicktreeitem_spec.rb +72 -72
  72. data/spec/operawatir/desktop/quicktreeview_spec.rb +13 -13
  73. data/spec/operawatir/desktop/quickwidget_spec.rb +51 -13
  74. data/spec/operawatir/desktop/quickwindow_spec.rb +4 -0
  75. data/spec/operawatir/desktop/shared/shared.rb +25 -9
  76. data/spec/operawatir/fixtures/draggableLists.html +67 -0
  77. data/spec/operawatir/fixtures/formSelectionPage.html +46 -0
  78. data/spec/operawatir/fixtures/js/jquery-1.4.4.min.js +167 -0
  79. data/spec/operawatir/fixtures/js/jquery-ui-1.8.10.custom.min.js +782 -0
  80. data/spec/operawatir/fixtures/keys.html +40 -0
  81. data/spec/operawatir/fixtures/label_submit.html +5 -0
  82. data/spec/operawatir/fixtures/mouse.html +59 -0
  83. data/spec/operawatir/fixtures/simple.html +10 -0
  84. data/spec/operawatir/matchers.rb +20 -19
  85. data/spec/operawatir/watirspec_desktophelper.rb +51 -3
  86. data/spec/operawatir/watirspec_helper.rb +0 -2
  87. metadata +91 -220
  88. data/lib/operadriver/client-combined-nodeps.jar +0 -0
  89. data/lib/operadriver/webdriver-opera.jar +0 -0
  90. data/spec/watir3/browser_spec.rb +0 -190
  91. data/spec/watir3/clipboard_spec.rb +0 -64
  92. data/spec/watir3/collection_spec.rb +0 -387
  93. data/spec/watir3/element_spec.rb +0 -474
  94. data/spec/watir3/guards.rb +0 -39
  95. data/spec/watir3/keys_spec.rb +0 -204
  96. data/spec/watir3/server.rb +0 -91
  97. data/spec/watir3/watirspec_helper.rb +0 -62
  98. data/spec/watir3/window_spec.rb +0 -295
Binary file
@@ -1,190 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path('../watirspec_helper', __FILE__)
3
-
4
- describe 'Browser' do
5
-
6
- before :all do
7
- browser.url = fixture('simple.html')
8
- end
9
-
10
- describe '#new' do
11
- it 'constructs a new instance' do
12
- browser.exists?.should be_true
13
- end
14
- end
15
-
16
- describe '#driver' do
17
- it 'returns driver object' do
18
- browser.driver.instance_of?(Java::ComOperaCoreSystems::OperaDriver).should be_true
19
- end
20
-
21
- it 'can access native driver methods' do
22
- browser.driver.getCurrentUrl.should_not be_empty
23
- end
24
- end
25
-
26
- describe '#name' do
27
- # FIXME
28
- it 'is the name of a Watir implementation' do
29
- browser.name.should_not be_empty
30
- end
31
- end
32
-
33
- describe '#url=' do # goto() is an alias
34
- it 'opens a new window' do
35
- new_window = browser.url fixture('simple.html')
36
- new_window.exists?.should be_true
37
- new_window.close
38
- end
39
-
40
- it 'navigates to a url' do
41
- window.url = fixture('simple.html')
42
- window.url.should == fixture('simple.html')
43
- end
44
-
45
- it 'navigates to a url using goto alias' do
46
- browser.goto fixture('simple.html')
47
- browser.active_window.url.should == fixture('simple.html')
48
- end
49
- end
50
-
51
- describe '#quit' do
52
- it 'exists' do
53
- browser.should respond_to :quit
54
- end
55
-
56
- =begin
57
- before :each do
58
- browser.quit
59
- end
60
-
61
- it 'quits the browser' do
62
- browser.connected?.should be_false
63
- end
64
-
65
- it 'window is closed upon quit' do
66
- browser.active_window.exists?.should be_false
67
- end
68
-
69
- it 'windows are closed upon quit' do
70
- browser.windows.all? do |window|
71
- window.exists? == false
72
- end.should be_true
73
- end
74
-
75
- it 'is not possible to access window properties after quit' do
76
- # FIXME
77
- browser.active_window.url.should raise_error NativeException
78
- browser.active_window.title.should raise_error NativeException
79
- end
80
-
81
- after :all do
82
- # OperaWatir::Helper.reconnect
83
- end
84
- =end
85
-
86
- end
87
-
88
-
89
-
90
- =begin
91
- describe '#windows' do
92
- before :all do
93
- puts 'AFTER QUIT!'
94
- # browser = OperaWatir::Browser.new
95
- puts "URL IS NOW: #{browser.active_window.url}"
96
- end
97
-
98
-
99
- it 'is not empty' do
100
- browser.windows.should_not be_empty
101
- end
102
-
103
- it 'is a list of open windows' do
104
- browser.windows.all? do |window|
105
- window.respond_to? :find_elements_by_id
106
- end.should be_true
107
- end
108
-
109
- it 'will close all open windows' do
110
- open_windows = browser.windows.length
111
- browser.windows.close_all
112
- browser.windows.length.should < open_windows
113
- browser.windows.length.should_not be_zero
114
- end
115
-
116
- # TODO: Window selectors
117
-
118
- end
119
- =end
120
-
121
- describe '#platform' do
122
- it 'fetches the platform the browser is running on' do
123
- # TODO: Improve regexp
124
- browser.platform.should match /linux|windows|mac os x|bsd/i
125
- end
126
- end
127
-
128
- describe '#path' do
129
- it 'fetches the full path to the binary of the attached browser' do
130
- # TODO: Improve regexp
131
- browser.path.should match /(\/|\\){2,}/
132
- end
133
- end
134
-
135
- describe '#ua_string' do
136
- it 'fetches the UA string of the browser' do
137
- browser.ua_string.should_not be_empty
138
- end
139
- end
140
-
141
- describe '#connected?' do
142
- it 'is attached to a browser instance' do
143
- browser.connected?.should be_true
144
- end
145
- =begin
146
- it 'is not attached to a browser instance' do
147
- browser.quit
148
- browser.connected?.should be_false
149
- end
150
- =end
151
- end
152
-
153
- describe '#desktop?' do
154
- it 'responds with boolean' do
155
- (!!browser.desktop? == browser.desktop?).should be_true
156
- end
157
- end
158
-
159
- # configuration
160
- describe '#speed' do
161
- it 'is one of :fast, :medium or :slow' do
162
- [:fast, :medium, :slow].any? do |speed|
163
- browser.speed == speed
164
- end.should be_true
165
- end
166
- end
167
-
168
- describe '#speed=' do
169
- it 'can be set to :fast' do
170
- browser.speed = :fast
171
- browser.speed.should == :fast
172
- end
173
-
174
- it 'can be set to :medium' do
175
- browser.speed = :medium
176
- browser.speed.should == :medium
177
- end
178
-
179
- it 'can be set to :slow' do
180
- browser.speed = :slow
181
- browser.speed.should == :slow
182
- end
183
-
184
- it 'cannot be set to other values' do
185
- browser.speed = :hoobaflooba
186
- browser.speed.should_not == :hoobaflooba
187
- end
188
- end
189
-
190
- end
@@ -1,64 +0,0 @@
1
- require File.expand_path('../watirspec_helper', __FILE__)
2
-
3
- # These tests use the clipboard gem. On GNU/Linux, this gem requires
4
- # the xclip package to be installed. On Windows and Mac, it should
5
- # work out of the box.
6
- require 'clipboard'
7
-
8
- describe 'Browser' do
9
-
10
- before :each do
11
- Clipboard.clear
12
- browser.url = fixture('input_fields_value.html')
13
- window.find_by_id('one').click
14
- browser.select_all
15
- end
16
-
17
- describe '#select_all' do
18
- it 'selects the value of an input field' do
19
- window.execute_script('one = document.getElementById("one");')
20
- window.execute_script('one.value.substr(one.selectionStart, one.selectionEnd - one.selectionStart)').to_s.should == 'foobar'
21
- end
22
- end
23
-
24
- describe '#copy' do
25
- it 'copies a string to the keyboard' do
26
- browser.copy
27
- Clipboard.paste.should == 'foobar'
28
- end
29
-
30
- it 'leaves the copied string alone' do
31
- browser.copy
32
- window.find_by_id('one').value.should == 'foobar'
33
- end
34
- end
35
-
36
- describe '#cut' do
37
- it 'copies a string to the keyboard' do
38
- browser.cut
39
- Clipboard.paste.should == 'foobar'
40
- end
41
-
42
- it 'removes the cut string' do
43
- browser.cut
44
- window.find_by_id('one').value.should == ''
45
- end
46
- end
47
-
48
- describe '#paste' do
49
- it 'pastes a copied string' do
50
- browser.copy
51
- window.find_by_id('two').click
52
- browser.paste
53
- window.find_by_id('two').value.should == 'foobar'
54
- end
55
-
56
- it 'pastes a cut string' do
57
- browser.cut
58
- window.find_by_id('two').click
59
- browser.paste
60
- window.find_by_id('two').value.should == 'foobar'
61
- end
62
- end
63
-
64
- end
@@ -1,387 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path('../watirspec_helper', __FILE__)
3
-
4
- describe 'Collection' do
5
- before :each do
6
- browser.url = fixture('non_control_elements.html')
7
- @collection = window.find_by_tag(:div)
8
- end
9
-
10
- # elements
11
- describe '#find_by_id' do
12
- it 'returns an element with the given ID' do
13
- elements = @collection.find_by_id('header')
14
-
15
- elements.should_not be_empty
16
- elements.length.should == 1
17
- elements.first.attr(:id).should == 'header'
18
- end
19
-
20
- it 'finds multiple elements with the same id' do
21
- elements = @collection.find_by_id('lead')
22
- elements.length.should == 4
23
- end
24
- end
25
-
26
- describe '#find_by_tag' do
27
- it 'is not empty if the tag exists under the collection' do
28
- @collection.find_by_tag(:a).should_not be_empty
29
- end
30
-
31
- it 'contains all elements of the tag name under the collection' do
32
- as = @collection.find_by_tag(:a)
33
- as.length.should == 4
34
- as.all? do |element|
35
- element.tag_name.should match /a/i
36
- end.should be_true
37
- end
38
-
39
- it 'contains only elements restricted by the selector' do
40
- @collection.find_by_tag(:span, :title => 'Lorem ipsum').all? do |element|
41
- element.attr(:title) == 'Lorem ipsum'
42
- end.should be_true
43
- end
44
-
45
- it 'is empty if the elements do not exist' do
46
- @collection.find_by_tag(:hoobaflooba).should be_empty
47
- end
48
- end
49
-
50
- # css
51
- # we don't want a complete CSS selector test suite here, so just some common
52
- # selectors
53
- describe '#find_by_css' do
54
- it 'is not empty if an element matches the css selector' do
55
- @collection.find_by_css('ul').should_not be_empty
56
- end
57
-
58
- it 'contains all elements selected by the selector' do
59
- collection = window.find_by_id('outer_container')
60
- divs = collection.find_by_css('div')
61
- divs.length.should == 7
62
- divs[1].id.should == 'promo'
63
- divs[3].id.should == 'best_language'
64
- divs[6].id.should == 'hidden'
65
- end
66
-
67
- it 'is empty if the selector does not match' do
68
- @collection.find_by_css('#hoobaflooba').should be_empty
69
- end
70
- end
71
-
72
- # class
73
- describe '#find_by_class' do
74
- it 'is not empty if an element matches the class' do
75
- @collection.find_by_class(:lead).should_not be_empty
76
- end
77
-
78
- it 'contains all elements with the given class' do
79
- collection = window.find_by_id('promo')
80
- leads = @collection.find_by_class(:lead)
81
- leads.length.should == 4
82
- leads.all? do |element|
83
- element.attr(:class).should match /lead/
84
- end.should be_true
85
-
86
- end
87
-
88
- it 'finds elements with multiple classes' do
89
- collection = window.find_by_id('header')
90
- collection.find_by_class(:one).all? do |element|
91
- element.attr(:class).should match /one/
92
- end.should be_true
93
- end
94
-
95
- it 'is empty if the class does not match' do
96
- @collection.find_by_class(:hoobaflooba).should be_empty
97
- end
98
- end
99
-
100
- # xpath
101
- describe '#find_by_xpath' do
102
- before :each do
103
- @headers = @collection.find_by_xpath('//h1')
104
- end
105
-
106
- it 'is not empty if elements matches the class' do
107
- @headers.should_not be_empty
108
- end
109
-
110
- it 'contains all elements with the given query' do
111
- @headers.all? do |element|
112
- element.tag_name.should match /h1/i
113
- end
114
- end
115
-
116
- it 'is empty if the query does not match' do
117
- @collection.find_by_xpath('//hoobaflooba').should be_empty
118
- end
119
-
120
- it 'finds elements in the current context' do
121
- subdivs = @collection.find_by_xpath('div')
122
- subdivs.length.should == 7
123
-
124
- # XPath spec says order not guaranteed, so just check they're here
125
- ids = subdivs.map { |el| el.id }
126
- ids.should include 'promo'
127
- ids.should include 'best_language'
128
- ids.should include 'hidden'
129
- end
130
- end
131
-
132
- # sugar
133
- describe 'syntactic sugar' do
134
- it 'returns all descendants with the given tag' do
135
- window.find_by_id('promo').span.length.should == 5
136
- end
137
-
138
- it 'can be chained' do
139
- lis = window.find_by_id('promo').ul.li
140
- lis[0].text.should == 'Abietic acid, C20H30O2'
141
- lis[2].text.should == 'Acenaphthoquinone, C12H6O2'
142
- lis[4].text.should == 'Acetaldehyde (ethanal), CH3CHO'
143
- end
144
-
145
- it 'can be chained deeply' do
146
- window.body.div.div.ul.li.a.id.should == [nil, 'link_2', 'link_3']
147
- end
148
-
149
- it 'returns the same as #find_by_tag' do
150
- @collection.span(:title => 'Lorem ipsum').should == @collection.find_by_tag(:span, :title => 'Lorem ipsum')
151
- end
152
-
153
- # This may be unnecessary...
154
- it 'responds to html elements' do
155
- [:a,:abbr,:address,:area,:article,:aside,:audio,:b,:base,:bdo,:blockquote,:body,
156
- :br,:button,:canvas,:caption,:cite,:code,:col,:colgroup,:command,:datalist,:dd,
157
- :del,:details,:dfn,:div,:dl,:dt,:em,:embed,:eventsource,:fieldset,:figcaption,
158
- :figure,:footer,:form,:h1,:h2,:h3,:h4,:h5,:h6,:head,:header,:hgroup,:hr,:i,
159
- :iframe,:img,:input,:ins,:kbd,:keygen,:label,:legend,:li,:link,:mark,:map,
160
- :menu,:meta,:meter,:nav,:noscript,:object,:ol,:optgroup,:option,:output,:p,
161
- :param,:pre,:progress,:q,:ruby,:rp,:rt,:samp,:script,:section,:select,:small,
162
- :source,:span,:strong,:style,:sub,:summary,:sup,:table,:tbody,:td,:textarea,
163
- :tfoot,:th,:thead,:time,:title,:tr,:ul,:var,:video,:wbr].all? do |symbol|
164
- @collection.respond_to? symbol
165
- end.should be_true
166
- end
167
-
168
- end
169
-
170
- # length
171
- describe '#length' do
172
- it 'is the number of items in the collection' do
173
- @collection.length.should == 12
174
- end
175
- end
176
-
177
- # item access
178
- describe '#[]' do
179
- it 'accesses the elements in the collection' do
180
- @collection[5].attr(:id).should == "best_language"
181
- @collection[@collection.length-1].attr(:id).should == "del_tag_test"
182
- end
183
- end
184
-
185
- describe '#attr' do
186
- it 'returns the given attribute of the first element' do
187
- collection = window.find_by_class('external')
188
- collection.attr(:id).should == 'link_2'
189
- end
190
- end
191
-
192
- # attrs(what)
193
- describe 'attrs' do
194
- it 'returns the attributes of each of the elements in the collection' do
195
- @collection.attrs(:id)[1].should == 'outer_container'
196
- @collection.attrs(:id)[2].should == 'header'
197
- @collection.attrs(:id)[9].should == 'messages'
198
- end
199
- end
200
-
201
- # id
202
- describe '#id' do
203
- it 'is the id attribute if there is one element' do
204
- window.find_by_class("primary").id.should == "first_header"
205
- end
206
-
207
- it 'is nil if the single element has no id' do
208
- window.find_by_class("php").id.should == nil
209
- end
210
-
211
- it 'is an array of ids if there is more than one element' do
212
- window.find_by_class("external").id.should == ["link_2", "link_3"]
213
- end
214
- end
215
-
216
- # class
217
- # TODO this is the class attribute, so it could have multiple classes, in
218
- # which case this name doesn't make much sense
219
- describe '#class_name' do
220
- it 'is the class attribute if there in one element' do
221
- window.find_by_id("favorite_compounds").class_name.should == "chemistry"
222
- end
223
-
224
- it 'is nil if the single element has no class' do
225
- window.find_by_id("outer_container").class_name.should == nil
226
- end
227
-
228
- it 'is an array of class attributes if there is more than one element' do
229
- window.find_by_class('external').class_name.should == [
230
- 'external one two', 'external'
231
- ]
232
- end
233
-
234
- it 'is an array with nil elements when the elements have no class' do
235
- window.find_by_tag("a").class_name.should == [
236
- nil, 'external one two', 'external', nil
237
- ]
238
- end
239
- end
240
-
241
- describe '#tag_name' do
242
- it 'is the tag name if there is one element' do
243
- window.find_by_id('header4').tag_name.should == 'H4'
244
- end
245
-
246
- it 'is an array if there are more than one elements' do
247
- window.find_by_class('lead').tag_name.should == ['SPAN', 'P', 'INS', 'DEL']
248
- end
249
- end
250
-
251
- # states
252
- # ------
253
-
254
- describe '#click' do
255
- it 'clicks all the elements in this collection' do
256
- collection = window.find_by_class('footer')
257
- collection.click
258
- collection.all? do |element|
259
- element.text.match(/Javascript/) != nil
260
- end.should be_true
261
- end
262
- end
263
-
264
- # checked?
265
- describe '#checked?' do
266
- before :each do
267
- browser.url = fixture('forms_with_input_elements.html')
268
- @boxes = window.find_by_tag(:input, :type => 'checkbox')
269
- end
270
-
271
- it 'is true if all of the elements are checked' do
272
- @boxes.each do |box|
273
- box.check!
274
- end
275
- @boxes.checked?.should be_true
276
- end
277
-
278
- it 'is false if one of the elements is not checked' do
279
- @boxes.checked?.should be_false
280
- end
281
- end
282
-
283
- # check!
284
- describe '#check!' do
285
- it 'checks all of the checkboxes' do
286
- browser.url = fixture('forms_with_input_elements.html')
287
- @boxes = window.find_by_tag(:input, :type => 'checkbox')
288
-
289
- @boxes.check!
290
- @boxes.all? do |box|
291
- box.checked? == true
292
- end.should be_true
293
- end
294
- end
295
-
296
- # uncheck!
297
- describe '#uncheck!' do
298
- it 'unchecks all of the checkboxes' do
299
- browser.url = fixture('forms_with_input_elements.html')
300
- @boxes = window.find_by_tag(:input, :type => 'checkbox')
301
-
302
- @boxes.uncheck!
303
- @boxes.all? do |box|
304
- box.checked? == false
305
- end.should be_true
306
- end
307
- end
308
-
309
- # toggle_check!
310
- describe '#toggle_check!' do
311
- it 'toggles the checked state of all of the checkboxes' do
312
- browser.url = fixture('forms_with_input_elements.html')
313
- @boxes = window.find_by_tag(:input, :type => 'checkbox')
314
-
315
- # Store the initial values
316
- values = @boxes.map { |el| el.checked? }
317
-
318
- @boxes.toggle_check!
319
-
320
- # Check they've all changed
321
- (0..values.size-1).all do |i|
322
- @boxes[i].checked? == !values[i]
323
- end.should be_true
324
- end
325
- end
326
-
327
- # enabled?
328
- describe '#enabled?' do
329
- before :each do
330
- browser.url = fixture('forms_with_input_elements.html')
331
- end
332
-
333
- it 'returns true if all collection elements are enabled' do
334
- window.find_by_id('delete_user').fieldset.first.option.enabled? should be_true
335
- end
336
-
337
- it 'returns false if any collection elements are disabled' do
338
- window.find_by_id('new_user').input.enabled?.should be_false
339
- end
340
- end
341
-
342
- # enable!
343
- describe '#enable!' do
344
- it 'enables all elements in the collection' do
345
- browser.url = fixture('forms_with_input_elements.html')
346
- window.find_by_id('new_user').input.enable!
347
- window.find_by_id('new_user_species').first.enabled?.should be_true
348
- end
349
- end
350
-
351
- # disable!
352
- describe '#disable!' do
353
- it 'disables all elements in the collection' do
354
- browser.url = fixture('forms_with_input_elements.html')
355
- window.find_by_id('new_user').input.disable!
356
- window.find_by_id('new_user_species').input.any? do |element|
357
- element.enabled?
358
- end.should be_false
359
- end
360
- end
361
-
362
- # visible?
363
- describe '#visible?' do
364
- it 'is true if all the elements are visible' do
365
- window.find_by_tag(:ul).visible?.should be_true
366
- end
367
-
368
- it 'is false if not all elements are visible' do
369
- @collection.visible?.should be_false
370
- end
371
- end
372
- # show!
373
- describe '#show!' do
374
- it 'shows all the elements' do
375
- @collection.show!
376
- window.find_by_id('hidden').visible?.should be_true
377
- end
378
- end
379
-
380
- # hide!
381
- describe '#hide!' do
382
- it 'hides all the elements' do
383
- @collection.hide!
384
- window.find_by_id('outer_container').visible?.should be_false
385
- end
386
- end
387
- end