operawatir 0.4.3.pre1-jruby → 0.5-jruby

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.
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
@@ -0,0 +1,202 @@
1
+ require File.expand_path('../../watirspec_helper', __FILE__)
2
+
3
+ describe OperaWatir::Actions do
4
+
5
+ before :each do
6
+ @actions = browser.actions
7
+ end
8
+
9
+ it 'is available on the browser object' do
10
+ browser.should.respond_to? :actions
11
+ actions = browser.actions
12
+ [:key_down, :key_up, :send_keys, :click_and_hold, :release, :click,
13
+ :double_click, :move_to_element, :move_by_offset, :context_click,
14
+ :drag_and_drop, :perform].each do |method|
15
+ actions.should.respond_to? method
16
+ end
17
+ end
18
+
19
+ describe 'keyboard' do
20
+ it 'types on element' do
21
+ browser.url = fixture('input_fields_value.html')
22
+
23
+ el = browser.text_field(:id => 'two')
24
+ @actions.send_keys(el, 'abc def').perform()
25
+ el.text.should == 'abc def'
26
+ end
27
+
28
+ it 'fires key events' do
29
+ browser.url = fixture('keys.html')
30
+
31
+ @actions.send_keys('a').perform()
32
+ window.text.should include 'down, 65, A'
33
+ window.text.should include 'press, 97, a'
34
+ window.text.should include 'up, 65, A'
35
+ end
36
+
37
+ it 'fires key events for modifier keys' do
38
+ browser.url = fixture('keys.html')
39
+
40
+ @actions.key_down(:control).perform()
41
+ window.text.should include 'down, 17, , ctrl'
42
+ window.text.should_not include 'up, 17'
43
+
44
+ browser.actions.key_up(:control).perform()
45
+ window.text.should include 'up, 17'
46
+ end
47
+
48
+ it 'combines modifier keys' do
49
+ browser.url = fixture('keys.html')
50
+
51
+ @actions.key_down(:control).key_down(:shift).key_up(:control).key_up(:shift).perform()
52
+ window.text.should include 'down, 16, , ctrl,shift'
53
+ window.text.should include 'up, 17, , shift'
54
+ end
55
+
56
+ it 'types with shift pressed' do
57
+ browser.url = fixture('input_fields_value.html')
58
+ el = browser.text_field(:id => 'two')
59
+
60
+ @actions.key_down(el, :shift).send_keys(el, 'ab').key_up(el, :shift).perform()
61
+
62
+ el.text.should == 'AB'
63
+ end
64
+
65
+ it 'sends keys to active element' do
66
+ browser.url = fixture('input_fields_value.html')
67
+ el = browser.text_field(:id => 'two')
68
+
69
+ el.click()
70
+ @actions.send_keys('ab').perform()
71
+
72
+ el.text.should == 'ab'
73
+ end
74
+ end
75
+
76
+ describe 'mouse' do
77
+ it 'can be used to drag and drop' do
78
+ browser.url = fixture('draggableLists.html')
79
+ dragReporter = browser.p(:id => 'dragging_reports')
80
+
81
+ toDrag = browser.li(:id => 'rightitem-3')
82
+ dragInto = browser.ul(:id => 'sortable1')
83
+
84
+ dragReporter.text.should == 'Nothing happened.'
85
+
86
+ browser.actions.click_and_hold(toDrag).perform()
87
+
88
+ browser.actions.move_to_element(browser.li(:id => 'leftitem-4')).perform()
89
+
90
+ browser.actions.move_to_element(dragInto).perform()
91
+
92
+ dragReporter.text.should == 'Nothing happened. DragOut'
93
+
94
+ browser.actions.release(dragInto).perform();
95
+
96
+ dragReporter.text.should == 'Nothing happened. DragOut DropIn RightItem 3'
97
+
98
+ dragInto.lis.length.should == 6
99
+ end
100
+
101
+ it 'drags and drops' do
102
+ browser.url = fixture('draggableLists.html')
103
+ dragReporter = browser.p(:id => 'dragging_reports')
104
+
105
+ toDrag = browser.li(:id => 'rightitem-3')
106
+ dragInto = browser.ul(:id => 'sortable1')
107
+
108
+ dragReporter.text.should == 'Nothing happened.'
109
+
110
+ browser.actions.drag_and_drop(toDrag, dragInto).perform()
111
+
112
+ dragReporter.text.should == 'Nothing happened. DragOut DropIn RightItem 3'
113
+
114
+ dragInto.lis.length.should == 6
115
+ end
116
+
117
+ it 'double clicks' do
118
+ browser.url = fixture('mouse.html')
119
+ el = browser.div(:id => 'test')
120
+
121
+ @actions.double_click(el).perform()
122
+ window.text.should include 'dblclick'
123
+ end
124
+
125
+ it 'move and double clicks' do
126
+ browser.url = fixture('mouse.html')
127
+ el = browser.div(:id => 'test')
128
+
129
+ @actions.move_to_element(el).double_click().perform()
130
+ window.text.should include 'dblclick'
131
+ end
132
+
133
+ it 'context clicks' do
134
+ browser.url = fixture('mouse.html')
135
+ el = browser.div(:id => 'test')
136
+
137
+ @actions.context_click(el).perform()
138
+ window.text.should include 'mouseup 2'
139
+ browser.keys.send(:esc)
140
+ end
141
+
142
+ it 'move and clicks' do
143
+ browser.url = fixture('mouse.html')
144
+ el = browser.div(:id => 'test')
145
+
146
+ @actions.move_to_element(el).click().perform()
147
+ window.text.should include 'click 0'
148
+ end
149
+
150
+ it 'cannot move to a nil element' do
151
+ browser.url = fixture('mouse.html')
152
+
153
+ lambda { @actions.click().perform() }.should raise_error
154
+ end
155
+
156
+ it 'moves by an offset' do
157
+ browser.url = fixture('mouse.html')
158
+
159
+ @actions.move_to_element(browser.pre(:id => 'log')).move_by_offset(1, -30).click().perform()
160
+ window.text.should include 'click 0'
161
+ end
162
+
163
+ end
164
+
165
+ describe 'combined' do
166
+ it 'uses form elements' do
167
+
168
+ end
169
+
170
+ it 'selects multiple items' do
171
+ pending 'getLocation() for OPTION elements is a known bug in OperaDriver'
172
+
173
+ browser.url = fixture('formSelectionPage.html')
174
+
175
+ options = browser.options()
176
+
177
+ @actions.click(options[1]).key_down(:control).click(options[3]).click(options[4]).key_up(:control)
178
+ @actions.perform()
179
+
180
+ browser.button(:name => 'showselected').click()
181
+
182
+ browser.div(:id => 'result').text.should == 'emmental parmigiano cheddar'
183
+ end
184
+
185
+ it 'clicks on links' do
186
+ browser.url = fixture('grid.html')
187
+
188
+ @actions.click(browser.link(:text => 'A3')).perform()
189
+
190
+ browser.url.should include '#A3'
191
+ end
192
+
193
+ it 'clicks on links with an offset' do
194
+ browser.url = fixture('grid.html')
195
+
196
+ @actions.move_to_element(browser.link(:text => 'B2'), 1, 1).click().perform()
197
+
198
+ browser.url.should include '#B2'
199
+ end
200
+ end
201
+
202
+ end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path('../../watirspec_helper', __FILE__)
2
2
 
3
- describe 'Browser' do
3
+ describe OperaWatir::Browser do
4
4
 
5
5
  # Note: This method is deprecated, but still needs to be tested.
6
6
  describe '#opera_action' do
@@ -9,7 +9,7 @@ describe 'Browser' do
9
9
  window.find_by_id('one').click
10
10
  browser.opera_action('Select all')
11
11
  window.eval_js('one = document.getElementById("one");')
12
- window.eval_js('one.value.substr(one.selectionStart, one.selectionEnd - one.selectionStart)').to_s.should == 'foobar'
12
+ window.eval_js('one.value.substr(one.selectionStart, one.selectionEnd - one.selectionStart)').should == 'foobar'
13
13
  end
14
14
  end
15
15
 
@@ -17,8 +17,8 @@ describe 'Browser' do
17
17
  describe '#opera_action_list' do
18
18
  it 'returns a list of available Opera actions' do
19
19
  browser.url = 'about:blank'
20
- browser.opera_action_list.should include 'Copy'
21
- browser.opera_action_list.should include 'Paste'
20
+ browser.opera_action_list.should include 'copy'
21
+ browser.opera_action_list.should include 'paste'
22
22
  end
23
23
  end
24
24
 
@@ -40,7 +40,7 @@ describe 'Browser' do
40
40
  browser.key 'Down'
41
41
  browser.key 'Down'
42
42
  browser.key_up 'Shift'
43
- window.execute_script("document.activeElement.text;").to_s.should == 'C2'
43
+ window.execute_script("document.activeElement.text;").should == 'C2'
44
44
  end
45
45
  end
46
46
 
@@ -53,7 +53,7 @@ describe 'Browser' do
53
53
  browser.key 'Down'
54
54
  browser.key_up 'Shift'
55
55
  browser.key 'Down'
56
- window.execute_script("document.activeElement.text;").to_s.should == 'C2'
56
+ window.execute_script("document.activeElement.text;").should == 'C2'
57
57
  end
58
58
  end
59
59
 
@@ -69,13 +69,13 @@ describe 'Browser' do
69
69
 
70
70
  describe '#desktop?' do
71
71
  it 'returns true or false' do
72
- [true,false].should include browser.desktop?
72
+ [true, false].should include browser.desktop?
73
73
  end
74
74
  end
75
75
 
76
76
  describe '#version' do
77
77
  it 'fetches the version number of the driver' do
78
- browser.version.should match /\d{1,}\.\d{1,}\.\d{1,}/
78
+ browser.version.should_not be_empty
79
79
  end
80
80
  end
81
81
 
@@ -1,8 +1,17 @@
1
1
  require File.expand_path('../../watirspec_helper', __FILE__)
2
2
  require 'tmpdir'
3
3
 
4
- describe 'Element' do
5
-
4
+ describe OperaWatir::Element do
5
+
6
+ describe '#click' do
7
+ # TODO: Move to watirspec
8
+ it 'clicks LABEL elements tied to form submit' do
9
+ browser.url = fixture('label_submit.html')
10
+ window.find_by_tag('label').click
11
+ window.text.should include 'PASS'
12
+ end
13
+ end
14
+
6
15
  describe '#triple_click' do
7
16
  it 'clicks three times' do
8
17
  browser.url = fixture('onclick.html')
@@ -1,10 +1,18 @@
1
1
  require File.expand_path('../../watirspec_helper', __FILE__)
2
2
 
3
+ #
4
+ # TODO
5
+ #
6
+
7
+ =begin
3
8
  describe OperaWatir::Keys do
4
9
 
5
- before(:all) { browser.url = fixture('keys.html') }
10
+ before(:each) { browser.url = fixture('keys.html') }
11
+
12
+ let(:keys) { browser.keys }
13
+ let(:keyboard) { window.pre(:id => 'log').text }
6
14
 
7
- let(:log) { window.pre(:id => 'log') }
15
+ subject { keyboard }
8
16
 
9
17
  describe '#down' do
10
18
  it 'presses one key' do
@@ -15,12 +23,52 @@ describe OperaWatir::Keys do
15
23
  end
16
24
 
17
25
  describe '#up' do
26
+ it 'releases one key' do
27
+ end
28
+
29
+ it 'releases series of keys' do
30
+ end
18
31
  end
19
32
 
20
33
  describe '#release' do
34
+ it 'releases one key' do
35
+ keys.down 'a'
36
+ keyboard.should hold_down_keys 'a'
37
+ keys.release
38
+ keyboard.should_not hold_down_keys 'a'
39
+ end
40
+
41
+ it 'releases one modifier key' do
42
+ keys.down :shift
43
+ keyboard.should hold_down_keys :shift
44
+ keys.release
45
+ keyboard.should_not hold_down_keys :shift
46
+ end
47
+
48
+ it 'releases several keys' do
49
+ keys.down 'a', 'b'
50
+ keyboard.should hold_down_keys 'a', 'b'
51
+ keys.release
52
+ keyboard.should_not hold_down_keys 'a', 'b'
53
+ end
54
+
55
+ it 'releases several modifier keys' do
56
+ keys.down :shift, :control
57
+ keyboard.should hold_down_keys :shift, :control
58
+ keys.release
59
+ keyboard.should_not hold_down_keys :shift, :control
60
+ end
61
+
62
+ it 'releases a combination of keys and modifier keys' do
63
+ keys.down :shift, :control, 'a'
64
+ keyboard.should hold_down_keys :shift, :control, 'a'
65
+ keys.release
66
+ keyboard.should_not hold_down_keys :shift, :control, 'a'
67
+ end
21
68
  end
22
69
 
23
70
  describe '#send' do
24
71
  end
25
72
 
26
73
  end
74
+ =end
@@ -1,10 +1,11 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require File.expand_path('../../watirspec_helper', __FILE__)
3
3
 
4
- describe 'Preferences' do
4
+ describe OperaWatir::Preferences do
5
5
 
6
6
  before :all do
7
7
  @prefs = browser.preferences
8
+ @old_prefs = @prefs.to_a
8
9
  end
9
10
 
10
11
  describe '#new' do
@@ -17,7 +18,7 @@ describe 'Preferences' do
17
18
  describe '#each' do
18
19
  it 'contains a list of entries' do
19
20
  @prefs.each do |p|
20
- p.should be_kind_of OperaWatir::Preferences::Entry
21
+ p.should be_kind_of OperaWatir::Preferences::Section
21
22
  end
22
23
  end
23
24
  end
@@ -38,11 +39,7 @@ describe 'Preferences' do
38
39
 
39
40
  describe '#first' do
40
41
  it 'is a valid entry' do
41
- @prefs.first.should be_kind_of OperaWatir::Preferences::Entry
42
- end
43
-
44
- it 'is a section' do
45
- @prefs.first.should be_section
42
+ @prefs.first.should be_kind_of OperaWatir::Preferences::Section
46
43
  end
47
44
 
48
45
  it 'has a key' do
@@ -56,11 +53,7 @@ describe 'Preferences' do
56
53
 
57
54
  describe '#last' do
58
55
  it 'is a valid entry' do
59
- @prefs.last.should be_kind_of OperaWatir::Preferences::Entry
60
- end
61
-
62
- it 'is a section' do
63
- @prefs.last.should be_section
56
+ @prefs.last.should be_kind_of OperaWatir::Preferences::Section
64
57
  end
65
58
 
66
59
  it 'has a key' do
@@ -117,8 +110,8 @@ describe 'Preferences' do
117
110
  @array.should be_kind_of Array
118
111
  end
119
112
 
120
- it 'returns entries of the type Preference::Entry' do
121
- @array[0].should be_kind_of OperaWatir::Preferences::Entry
113
+ it 'returns entries of the type Preference::Section' do
114
+ @array[0].should be_kind_of OperaWatir::Preferences::Section
122
115
  end
123
116
 
124
117
  it 'has several entries' do
@@ -131,7 +124,7 @@ describe 'Preferences' do
131
124
  end
132
125
  end
133
126
 
134
- describe 'Section' do # Preferences::Entry / Preferences#method_missing
127
+ describe OperaWatir::Preferences::Section do
135
128
 
136
129
  before :all do
137
130
  @section = @prefs.link
@@ -139,8 +132,7 @@ describe 'Preferences' do
139
132
 
140
133
  describe '#new' do
141
134
  it 'constructs a new instance' do
142
- @section.should exist
143
- @section.should be_kind_of OperaWatir::Preferences::Entry
135
+ @section.should be_kind_of OperaWatir::Preferences::Section
144
136
  end
145
137
  end
146
138
 
@@ -162,58 +154,10 @@ describe 'Preferences' do
162
154
  end
163
155
  end
164
156
 
165
- describe '#value' do
166
- it 'raises exception' do
167
- lambda { @section.value }.should raise_error OperaWatir::Exceptions::PreferencesException
168
- end
169
- end
170
-
171
- describe '#value=' do
172
- it 'raises exception' do
173
- lambda { @section.value = 'hoobaflooba' }.should raise_error OperaWatir::Exceptions::PreferencesException
174
- end
175
- end
176
-
177
- describe '#default' do
178
- it 'raises exception' do
179
- lambda { @section.default }.should raise_error OperaWatir::Exceptions::PreferencesException
180
- end
181
- end
182
-
183
- describe '#default!' do
184
- it 'raises exception' do
185
- lambda { @section.default! }.should raise_error OperaWatir::Exceptions::PreferencesException
186
- end
187
- end
188
-
189
- describe '#section?' do
190
- it 'returns a valid type' do
191
- @section.section?.should be_kind_of TrueClass
192
- end
193
-
194
- it 'is a section' do
195
- @section.section?.should be_true
196
- end
197
- end
198
-
199
- describe '#exists?' do
200
- it 'returns a valid type' do
201
- @section.exists?.should be_kind_of TrueClass
202
- end
203
-
204
- it 'exists' do
205
- @section.exists?.should be_true
206
- end
207
-
208
- it 'responds to alias #exist?' do
209
- @section.exist?.should == @section.exists?
210
- end
211
- end
212
-
213
157
  describe '#each' do
214
158
  it 'contains a list of entries' do
215
159
  @section.each do |k|
216
- k.should be_kind_of OperaWatir::Preferences::Entry
160
+ k.should be_kind_of OperaWatir::Preferences::Section::Key
217
161
  end
218
162
  end
219
163
  end
@@ -234,17 +178,13 @@ describe 'Preferences' do
234
178
 
235
179
  describe '#first' do
236
180
  it 'is a valid entry' do
237
- @section.first.should be_kind_of OperaWatir::Preferences::Entry
181
+ @section.first.should be_kind_of OperaWatir::Preferences::Section::Key
238
182
  end
239
183
 
240
184
  it 'has a key' do
241
185
  @section.first.key.should_not be_empty
242
186
  end
243
187
 
244
- it 'has a key which is not a section' do
245
- @section.first.should_not be_section
246
- end
247
-
248
188
  it 'has a key with a method' do
249
189
  @section.first.method.should match /^([a-z_]+)/
250
190
  end
@@ -252,17 +192,13 @@ describe 'Preferences' do
252
192
 
253
193
  describe '#last' do
254
194
  it 'is a valid entry' do
255
- @section.last.should be_kind_of OperaWatir::Preferences::Entry
195
+ @section.last.should be_kind_of OperaWatir::Preferences::Section::Key
256
196
  end
257
197
 
258
198
  it 'has a key' do
259
199
  @section.last.key.should_not be_empty
260
200
  end
261
201
 
262
- it 'is a key which is not section' do
263
- @section.last.should_not be_section
264
- end
265
-
266
202
  it 'has a key with a method' do
267
203
  @section.last.method.should match /^([a-z_]+)/
268
204
  end
@@ -278,15 +214,14 @@ describe 'Preferences' do
278
214
  end
279
215
  end
280
216
 
281
- describe 'Keys' do # Preferences::Entry / Entry#method_missing
282
-
217
+ describe OperaWatir::Preferences::Section::Key do
283
218
  before :all do
284
219
  @key = @section.expiry
285
220
  end
286
221
 
287
222
  describe '#parent' do
288
223
  it 'contains the parent class' do
289
- @key.parent.should be_kind_of OperaWatir::Preferences::Entry
224
+ @key.parent.should be_kind_of OperaWatir::Preferences::Section
290
225
  end
291
226
  end
292
227
 
@@ -307,15 +242,15 @@ describe 'Preferences' do
307
242
  # Note that the types aren't proper Ruby objects, but strings.
308
243
 
309
244
  it '`expiry` is a type integer' do
310
- @key.type.should include 'Integer'
245
+ @key.type.should match /integer/i
311
246
  end
312
247
 
313
248
  it '`color` is a type boolean' do
314
- @section.color.type.should include 'Boolean'
249
+ @section.color.type.should match /boolean/i
315
250
  end
316
251
 
317
252
  it '`opera_account.server_address` is a type string' do
318
- @prefs.opera_account.server_address.type.should include 'String'
253
+ @prefs.opera_account.server_address.type.should match /string/i
319
254
  end
320
255
  end
321
256
 
@@ -342,8 +277,8 @@ describe 'Preferences' do
342
277
 
343
278
  it 'has effect in the browser when changed' do
344
279
  @section.strikethrough.value = '1' #true
345
- window.url = fixture('../simple.html')
346
- window.a.execute_script('this.currentStyle.textDecoration').should include /strike\-through/
280
+ window.url = fixture('simple.html')
281
+ window.execute_script('document.getElementsByTagName("a")[0].currentStyle.textDecoration').should include 'line-through'
347
282
  end
348
283
 
349
284
  # JRUBY-1127 makes it impossible to unwrap Java exceptions in JRuby.
@@ -380,59 +315,40 @@ describe 'Preferences' do
380
315
  end
381
316
  end
382
317
 
383
- describe '#section?' do
384
- it 'returns a valid type' do
385
- @key.section?.should be_kind_of FalseClass
386
- end
387
-
388
- it 'is not a section' do
389
- @key.section?.should be_false
390
- end
391
- end
392
-
393
- describe '#each' do
394
- it 'raises error' do
395
- lambda { @key.each { |e| } }.should raise_error OperaWatir::Exceptions::PreferencesException
396
- end
397
- end
318
+ end
398
319
 
399
- describe '#length' do
400
- it 'raises error' do
401
- lambda { @key.length }.should raise_error OperaWatir::Exceptions::PreferencesException
402
- end
320
+ end
403
321
 
404
- it 'responds to alias #size' do
405
- lambda { @key.size }.should raise_error OperaWatir::Exceptions::PreferencesException
406
- end
407
- end
322
+ =begin
323
+ describe '#cleanup' do
324
+ it 'returns an array' do
325
+ @prefs.cleanup.should be_kind_of Array
326
+ end
408
327
 
409
- describe '#first' do
410
- it 'raises error' do
411
- lambda { @key.first }.should raise_error OperaWatir::Exceptions::PreferencesException
412
- end
413
- end
328
+ it 'matches the old stored prefs' do
329
+ @prefs.cleanup.should == @old_prefs
330
+ end
331
+ end
414
332
 
415
- describe '#last' do
416
- it 'raises error' do
417
- lambda { @key.last }.should raise_error OperaWatir::Exceptions::PreferencesException
418
- end
419
- end
333
+ describe '#cleanup!' do
334
+ before(:all) { @after_cleanup = @prefs.cleanup! }
420
335
 
421
- describe '#empty?' do
422
- it 'raises error' do
423
- lambda { @key.empty? }.should raise_error OperaWatir::Exceptions::PreferencesException
424
- end
425
- end
336
+ it 'cleans up the preferences' do
337
+ @key.value.should_not == '1337'
338
+ end
426
339
 
340
+ it 'matches the old stored prefs' do
341
+ @after_cleanup.should == @old_prefs
427
342
  end
428
343
 
344
+ it 'returns an array' do
345
+ @after_cleanup.should be_kind_of Array
346
+ end
429
347
  end
348
+ =end
430
349
 
431
- describe '#cleanup' do; end # TODO
432
- describe '#cleanup!' do; end # TODO
433
-
434
- after :all do
435
- @prefs.cleanup!
436
- end
350
+ # after :all do
351
+ # @prefs.cleanup!
352
+ # end
437
353
 
438
354
  end