watir 6.13.0 → 6.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +141 -0
  3. data/.travis.yml +6 -0
  4. data/CHANGES.md +12 -0
  5. data/Gemfile +4 -10
  6. data/README.md +64 -49
  7. data/Rakefile +28 -16
  8. data/lib/watir.rb +13 -15
  9. data/lib/watir/adjacent.rb +15 -13
  10. data/lib/watir/after_hooks.rb +8 -10
  11. data/lib/watir/alert.rb +7 -8
  12. data/lib/watir/aliases.rb +2 -2
  13. data/lib/watir/attribute_helper.rb +18 -20
  14. data/lib/watir/browser.rb +42 -75
  15. data/lib/watir/capabilities.rb +19 -10
  16. data/lib/watir/cell_container.rb +0 -2
  17. data/lib/watir/container.rb +4 -4
  18. data/lib/watir/cookies.rb +7 -8
  19. data/lib/watir/element_collection.rb +37 -22
  20. data/lib/watir/elements/area.rb +0 -2
  21. data/lib/watir/elements/button.rb +1 -3
  22. data/lib/watir/elements/cell.rb +0 -1
  23. data/lib/watir/elements/checkbox.rb +5 -7
  24. data/lib/watir/elements/date_field.rb +5 -9
  25. data/lib/watir/elements/date_time_field.rb +6 -10
  26. data/lib/watir/elements/dlist.rb +2 -4
  27. data/lib/watir/elements/element.rb +201 -99
  28. data/lib/watir/elements/file_field.rb +3 -4
  29. data/lib/watir/elements/font.rb +2 -4
  30. data/lib/watir/elements/form.rb +0 -2
  31. data/lib/watir/elements/hidden.rb +3 -4
  32. data/lib/watir/elements/html_elements.rb +24 -76
  33. data/lib/watir/elements/iframe.rb +57 -71
  34. data/lib/watir/elements/image.rb +3 -4
  35. data/lib/watir/elements/input.rb +0 -2
  36. data/lib/watir/elements/link.rb +2 -5
  37. data/lib/watir/elements/list.rb +4 -4
  38. data/lib/watir/elements/option.rb +3 -6
  39. data/lib/watir/elements/radio.rb +4 -6
  40. data/lib/watir/elements/row.rb +0 -1
  41. data/lib/watir/elements/select.rb +41 -43
  42. data/lib/watir/elements/svg_elements.rb +0 -116
  43. data/lib/watir/elements/table.rb +1 -2
  44. data/lib/watir/elements/table_cell.rb +2 -3
  45. data/lib/watir/elements/text_field.rb +4 -6
  46. data/lib/watir/exception.rb +0 -1
  47. data/lib/watir/extensions/nokogiri.rb +2 -4
  48. data/lib/watir/generator.rb +3 -3
  49. data/lib/watir/generator/base.rb +10 -10
  50. data/lib/watir/generator/base/generator.rb +26 -29
  51. data/lib/watir/generator/base/idl_sorter.rb +34 -32
  52. data/lib/watir/generator/base/spec_extractor.rb +132 -114
  53. data/lib/watir/generator/base/util.rb +1 -3
  54. data/lib/watir/generator/base/visitor.rb +140 -140
  55. data/lib/watir/generator/html.rb +4 -4
  56. data/lib/watir/generator/html/generator.rb +2 -4
  57. data/lib/watir/generator/html/spec_extractor.rb +33 -33
  58. data/lib/watir/generator/html/visitor.rb +14 -14
  59. data/lib/watir/generator/svg.rb +3 -3
  60. data/lib/watir/generator/svg/generator.rb +1 -3
  61. data/lib/watir/generator/svg/spec_extractor.rb +35 -35
  62. data/lib/watir/generator/svg/visitor.rb +14 -14
  63. data/lib/watir/has_window.rb +2 -4
  64. data/lib/watir/js_execution.rb +7 -9
  65. data/lib/watir/js_snippets.rb +3 -3
  66. data/lib/watir/js_snippets/attributeValues.js +11 -0
  67. data/lib/watir/legacy_wait.rb +7 -12
  68. data/lib/watir/locators.rb +9 -11
  69. data/lib/watir/locators/button/locator.rb +2 -3
  70. data/lib/watir/locators/button/selector_builder.rb +9 -9
  71. data/lib/watir/locators/button/selector_builder/xpath.rb +1 -1
  72. data/lib/watir/locators/button/validator.rb +2 -2
  73. data/lib/watir/locators/cell/locator.rb +0 -2
  74. data/lib/watir/locators/cell/selector_builder.rb +3 -5
  75. data/lib/watir/locators/element/locator.rb +85 -64
  76. data/lib/watir/locators/element/selector_builder.rb +40 -38
  77. data/lib/watir/locators/element/selector_builder/xpath.rb +20 -18
  78. data/lib/watir/locators/element/validator.rb +1 -1
  79. data/lib/watir/locators/row/locator.rb +0 -2
  80. data/lib/watir/locators/row/selector_builder.rb +6 -9
  81. data/lib/watir/locators/text_area/selector_builder.rb +1 -1
  82. data/lib/watir/locators/text_field/locator.rb +1 -3
  83. data/lib/watir/locators/text_field/selector_builder.rb +5 -5
  84. data/lib/watir/locators/text_field/selector_builder/xpath.rb +1 -1
  85. data/lib/watir/locators/text_field/validator.rb +3 -2
  86. data/lib/watir/logger.rb +11 -21
  87. data/lib/watir/navigation.rb +49 -0
  88. data/lib/watir/radio_set.rb +17 -18
  89. data/lib/watir/row_container.rb +3 -5
  90. data/lib/watir/screenshot.rb +2 -4
  91. data/lib/watir/user_editable.rb +13 -8
  92. data/lib/watir/version.rb +3 -0
  93. data/lib/watir/wait.rb +56 -55
  94. data/lib/watir/wait/timer.rb +1 -3
  95. data/lib/watir/window.rb +36 -45
  96. data/lib/watir/xpath_support.rb +1 -3
  97. data/lib/watirspec.rb +11 -11
  98. data/lib/watirspec/guards.rb +10 -7
  99. data/lib/watirspec/implementation.rb +3 -4
  100. data/lib/watirspec/rake_tasks.rb +30 -29
  101. data/lib/watirspec/remote_server.rb +3 -3
  102. data/lib/watirspec/runner.rb +1 -2
  103. data/lib/watirspec/server.rb +3 -0
  104. data/lib/watirspec/server/app.rb +14 -6
  105. data/spec/implementation_spec.rb +9 -9
  106. data/spec/locator_spec_helper.rb +3 -4
  107. data/spec/spec_helper.rb +3 -7
  108. data/spec/unit/container_spec.rb +9 -10
  109. data/spec/unit/element_locator_spec.rb +224 -219
  110. data/spec/unit/logger_spec.rb +4 -4
  111. data/spec/unit/unit_helper.rb +0 -2
  112. data/spec/unit/wait_spec.rb +26 -28
  113. data/spec/watirspec/adjacent_spec.rb +130 -130
  114. data/spec/watirspec/after_hooks_spec.rb +63 -63
  115. data/spec/watirspec/alert_spec.rb +6 -6
  116. data/spec/watirspec/attributes_spec.rb +6 -6
  117. data/spec/watirspec/browser_spec.rb +161 -162
  118. data/spec/watirspec/click_spec.rb +9 -9
  119. data/spec/watirspec/cookies_spec.rb +15 -14
  120. data/spec/watirspec/drag_and_drop_spec.rb +15 -16
  121. data/spec/watirspec/element_hidden_spec.rb +19 -21
  122. data/spec/watirspec/elements/area_spec.rb +18 -21
  123. data/spec/watirspec/elements/areas_spec.rb +13 -15
  124. data/spec/watirspec/elements/button_spec.rb +96 -99
  125. data/spec/watirspec/elements/buttons_spec.rb +17 -19
  126. data/spec/watirspec/elements/checkbox_spec.rb +102 -100
  127. data/spec/watirspec/elements/checkboxes_spec.rb +13 -15
  128. data/spec/watirspec/elements/collections_spec.rb +35 -37
  129. data/spec/watirspec/elements/date_field_spec.rb +46 -47
  130. data/spec/watirspec/elements/date_fields_spec.rb +13 -15
  131. data/spec/watirspec/elements/date_time_field_spec.rb +62 -57
  132. data/spec/watirspec/elements/date_time_fields_spec.rb +14 -15
  133. data/spec/watirspec/elements/dd_spec.rb +46 -48
  134. data/spec/watirspec/elements/dds_spec.rb +13 -15
  135. data/spec/watirspec/elements/del_spec.rb +27 -28
  136. data/spec/watirspec/elements/dels_spec.rb +13 -15
  137. data/spec/watirspec/elements/div_spec.rb +89 -91
  138. data/spec/watirspec/elements/divs_spec.rb +17 -19
  139. data/spec/watirspec/elements/dl_spec.rb +52 -54
  140. data/spec/watirspec/elements/dls_spec.rb +13 -15
  141. data/spec/watirspec/elements/dt_spec.rb +46 -48
  142. data/spec/watirspec/elements/dts_spec.rb +13 -15
  143. data/spec/watirspec/elements/element_spec.rb +240 -189
  144. data/spec/watirspec/elements/elements_spec.rb +16 -16
  145. data/spec/watirspec/elements/em_spec.rb +38 -40
  146. data/spec/watirspec/elements/ems_spec.rb +13 -15
  147. data/spec/watirspec/elements/filefield_spec.rb +45 -46
  148. data/spec/watirspec/elements/filefields_spec.rb +13 -15
  149. data/spec/watirspec/elements/font_spec.rb +11 -13
  150. data/spec/watirspec/elements/form_spec.rb +13 -15
  151. data/spec/watirspec/elements/forms_spec.rb +13 -15
  152. data/spec/watirspec/elements/frame_spec.rb +48 -50
  153. data/spec/watirspec/elements/frames_spec.rb +13 -15
  154. data/spec/watirspec/elements/hidden_spec.rb +23 -25
  155. data/spec/watirspec/elements/hiddens_spec.rb +13 -15
  156. data/spec/watirspec/elements/hn_spec.rb +22 -24
  157. data/spec/watirspec/elements/hns_spec.rb +13 -13
  158. data/spec/watirspec/elements/iframe_spec.rb +106 -74
  159. data/spec/watirspec/elements/iframes_spec.rb +16 -18
  160. data/spec/watirspec/elements/image_spec.rb +30 -32
  161. data/spec/watirspec/elements/images_spec.rb +13 -15
  162. data/spec/watirspec/elements/input_spec.rb +4 -5
  163. data/spec/watirspec/elements/ins_spec.rb +27 -29
  164. data/spec/watirspec/elements/inses_spec.rb +13 -15
  165. data/spec/watirspec/elements/label_spec.rb +17 -19
  166. data/spec/watirspec/elements/labels_spec.rb +13 -15
  167. data/spec/watirspec/elements/li_spec.rb +23 -25
  168. data/spec/watirspec/elements/link_spec.rb +45 -48
  169. data/spec/watirspec/elements/links_spec.rb +14 -16
  170. data/spec/watirspec/elements/lis_spec.rb +13 -15
  171. data/spec/watirspec/elements/list_spec.rb +14 -15
  172. data/spec/watirspec/elements/map_spec.rb +19 -20
  173. data/spec/watirspec/elements/maps_spec.rb +13 -15
  174. data/spec/watirspec/elements/meta_spec.rb +10 -10
  175. data/spec/watirspec/elements/metas_spec.rb +13 -15
  176. data/spec/watirspec/elements/ol_spec.rb +20 -21
  177. data/spec/watirspec/elements/ols_spec.rb +13 -15
  178. data/spec/watirspec/elements/option_spec.rb +63 -63
  179. data/spec/watirspec/elements/p_spec.rb +27 -26
  180. data/spec/watirspec/elements/pre_spec.rb +24 -25
  181. data/spec/watirspec/elements/pres_spec.rb +13 -15
  182. data/spec/watirspec/elements/ps_spec.rb +13 -15
  183. data/spec/watirspec/elements/radio_spec.rb +96 -97
  184. data/spec/watirspec/elements/radios_spec.rb +13 -15
  185. data/spec/watirspec/elements/select_list_spec.rb +244 -237
  186. data/spec/watirspec/elements/select_lists_spec.rb +15 -16
  187. data/spec/watirspec/elements/span_spec.rb +32 -31
  188. data/spec/watirspec/elements/spans_spec.rb +13 -15
  189. data/spec/watirspec/elements/strong_spec.rb +23 -24
  190. data/spec/watirspec/elements/strongs_spec.rb +13 -15
  191. data/spec/watirspec/elements/table_nesting_spec.rb +15 -14
  192. data/spec/watirspec/elements/table_spec.rb +61 -62
  193. data/spec/watirspec/elements/tables_spec.rb +15 -17
  194. data/spec/watirspec/elements/tbody_spec.rb +25 -26
  195. data/spec/watirspec/elements/tbodys_spec.rb +17 -19
  196. data/spec/watirspec/elements/td_spec.rb +20 -22
  197. data/spec/watirspec/elements/tds_spec.rb +9 -11
  198. data/spec/watirspec/elements/text_field_spec.rb +55 -56
  199. data/spec/watirspec/elements/text_fields_spec.rb +15 -16
  200. data/spec/watirspec/elements/textarea_spec.rb +2 -2
  201. data/spec/watirspec/elements/textareas_spec.rb +1 -1
  202. data/spec/watirspec/elements/tfoot_spec.rb +22 -23
  203. data/spec/watirspec/elements/tfoots_spec.rb +19 -19
  204. data/spec/watirspec/elements/thead_spec.rb +21 -23
  205. data/spec/watirspec/elements/theads_spec.rb +19 -19
  206. data/spec/watirspec/elements/tr_spec.rb +20 -22
  207. data/spec/watirspec/elements/trs_spec.rb +17 -19
  208. data/spec/watirspec/elements/ul_spec.rb +17 -19
  209. data/spec/watirspec/elements/uls_spec.rb +13 -14
  210. data/spec/watirspec/html/data_attributes.html +1 -0
  211. data/spec/watirspec/radio_set_spec.rb +100 -99
  212. data/spec/watirspec/relaxed_locate_spec.rb +19 -43
  213. data/spec/watirspec/screenshot_spec.rb +4 -4
  214. data/spec/watirspec/special_chars_spec.rb +2 -4
  215. data/spec/watirspec/support/rspec_matchers.rb +85 -22
  216. data/spec/watirspec/user_editable_spec.rb +84 -85
  217. data/spec/watirspec/wait_spec.rb +74 -95
  218. data/spec/watirspec/window_switching_spec.rb +131 -132
  219. data/spec/watirspec_helper.rb +12 -9
  220. data/support/travis.sh +4 -0
  221. data/support/version_differ.rb +12 -13
  222. data/watir.gemspec +29 -22
  223. metadata +76 -50
@@ -1,34 +1,33 @@
1
- require "watirspec_helper"
2
-
3
- describe "Table" do
1
+ require 'watirspec_helper'
4
2
 
3
+ describe 'Table' do
5
4
  before :each do
6
- browser.goto(WatirSpec.url_for("tables.html"))
5
+ browser.goto(WatirSpec.url_for('tables.html'))
7
6
  end
8
7
 
9
8
  # Exists
10
- describe "#exists?" do
11
- it "returns true if the table exists" do
9
+ describe '#exists?' do
10
+ it 'returns true if the table exists' do
12
11
  expect(browser.table(id: 'axis_example')).to exist
13
12
  expect(browser.table(id: /axis_example/)).to exist
14
13
  expect(browser.table(index: 0)).to exist
15
14
  expect(browser.table(xpath: "//table[@id='axis_example']")).to exist
16
15
  end
17
16
 
18
- it "returns the first table if given no args" do
17
+ it 'returns the first table if given no args' do
19
18
  expect(browser.table).to exist
20
19
  end
21
20
 
22
- it "returns false if the table does not exist" do
21
+ it 'returns false if the table does not exist' do
23
22
  expect(browser.table(id: 'no_such_id')).to_not exist
24
23
  expect(browser.table(id: /no_such_id/)).to_not exist
25
24
  expect(browser.table(index: 1337)).to_not exist
26
25
  expect(browser.table(xpath: "//table[@id='no_such_id']")).to_not exist
27
26
  end
28
27
 
29
- it "checks the tag name when locating by xpath" do
30
- expect(browser.table(xpath: "//table//td")).to_not exist
31
- expect(browser.table(xpath: "//table")).to exist
28
+ it 'checks the tag name when locating by xpath' do
29
+ expect(browser.table(xpath: '//table//td')).to_not exist
30
+ expect(browser.table(xpath: '//table')).to exist
32
31
  end
33
32
 
34
33
  it "raises TypeError when 'what' argument is invalid" do
@@ -37,116 +36,116 @@ describe "Table" do
37
36
  end
38
37
 
39
38
  # Other
40
- bug "Safari does not strip text", :safari do
41
- describe "#strings" do
42
- it "returns a two-dimensional array representation of the table" do
39
+ bug 'Safari does not strip text', :safari do
40
+ describe '#strings' do
41
+ it 'returns a two-dimensional array representation of the table' do
43
42
  expect(browser.table(id: 'inner').strings).to eq [
44
- ["Table 2, Row 1, Cell 1",
45
- "Table 2, Row 1, Cell 2"]
43
+ ['Table 2, Row 1, Cell 1',
44
+ 'Table 2, Row 1, Cell 2']
46
45
  ]
47
46
  expect(browser.table(id: 'outer').strings).to eq [
48
- ["Table 1, Row 1, Cell 1", "Table 1, Row 1, Cell 2"],
49
- ["Table 1, Row 2, Cell 1", "Table 1, Row 2, Cell 2\nTable 2, Row 1, Cell 1 Table 2, Row 1, Cell 2"],
50
- ["Table 1, Row 3, Cell 1", "Table 1, Row 3, Cell 2"]
51
- ]
47
+ ['Table 1, Row 1, Cell 1', 'Table 1, Row 1, Cell 2'],
48
+ ['Table 1, Row 2, Cell 1', "Table 1, Row 2, Cell 2\nTable 2, Row 1, Cell 1 Table 2, Row 1, Cell 2"],
49
+ ['Table 1, Row 3, Cell 1', 'Table 1, Row 3, Cell 2']
50
+ ]
52
51
  end
53
52
  end
54
53
  end
55
54
 
56
- describe "#headers" do
57
- it "returns the first row of a table as the header row" do
58
- headers = browser.table(id: "axis_example").headers
55
+ describe '#headers' do
56
+ it 'returns the first row of a table as the header row' do
57
+ headers = browser.table(id: 'axis_example').headers
59
58
  expect(headers).to be_a Watir::TableHeaderCellCollection
60
59
  expect(headers.size).to eq 4
61
60
  end
62
61
  end
63
62
 
64
- describe "#hashes" do
65
- it "returns an Array of Hashes for the common table usage" do
66
- expect(browser.table(id: "axis_example").hashes).to eq [
67
- { "" => "March 2008", "Before income tax" => "", "Income tax" => "", "After income tax" => "" },
68
- { "" => "Gregory House", "Before income tax" => "5 934", "Income tax" => "1 347", "After income tax" => "4 587" },
69
- { "" => "Hugh Laurie", "Before income tax" => "6 300", "Income tax" => "1 479", "After income tax" => "4 821" },
70
- { "" => "April 2008", "Before income tax" => "", "Income tax" => "", "After income tax" => "" },
71
- { "" => "Gregory House", "Before income tax" => "5 863", "Income tax" => "1 331", "After income tax" => "4 532" },
72
- { "" => "Hugh Laurie", "Before income tax" => "6 252", "Income tax" => "1 420", "After income tax" => "4 832" },
73
- { "" => "Sum", "Before income tax" => "24 349", "Income tax" => "5 577", "After income tax" => "18 722"},
63
+ describe '#hashes' do
64
+ it 'returns an Array of Hashes for the common table usage' do
65
+ array = [
66
+ {'' => 'March 2008', 'Before income tax' => '', 'Income tax' => '', 'After income tax' => ''},
67
+ {'' => 'Gregory House', 'Before income tax' => '5 934', 'Income tax' => '1 347', 'After income tax' => '4 587'},
68
+ {'' => 'Hugh Laurie', 'Before income tax' => '6 300', 'Income tax' => '1 479', 'After income tax' => '4 821'},
69
+ {'' => 'April 2008', 'Before income tax' => '', 'Income tax' => '', 'After income tax' => ''},
70
+ {'' => 'Gregory House', 'Before income tax' => '5 863', 'Income tax' => '1 331', 'After income tax' => '4 532'},
71
+ {'' => 'Hugh Laurie', 'Before income tax' => '6 252', 'Income tax' => '1 420', 'After income tax' => '4 832'},
72
+ {'' => 'Sum', 'Before income tax' => '24 349', 'Income tax' => '5 577', 'After income tax' => '18 722'}
74
73
  ]
74
+ expect(browser.table(id: 'axis_example').hashes).to eq array
75
75
  end
76
76
 
77
- it "raises an error if the table could not be parsed" do
78
- browser.goto(WatirSpec.url_for("uneven_table.html"))
77
+ it 'raises an error if the table could not be parsed' do
78
+ browser.goto(WatirSpec.url_for('uneven_table.html'))
79
79
 
80
80
  expect {
81
81
  browser.table.hashes
82
- }.to raise_error("row at index 0 has 2 cells, while header row has 3")
82
+ }.to raise_error('row at index 0 has 2 cells, while header row has 3')
83
83
  end
84
84
  end
85
85
 
86
- describe "#click" do
86
+ describe '#click' do
87
87
  it "fires the table's onclick event" do
88
88
  browser.table(id: 'inner').click
89
89
  expect(messages).to include('table')
90
90
  end
91
91
  end
92
92
 
93
- describe "#[]" do
94
- it "returns the nth child row" do
95
- expect(browser.table(id: 'outer')[0].id).to eq "outer_first"
96
- expect(browser.table(id: 'inner')[0].id).to eq "inner_first"
97
- expect(browser.table(id: 'outer')[2].id).to eq "outer_last"
93
+ describe '#[]' do
94
+ it 'returns the nth child row' do
95
+ expect(browser.table(id: 'outer')[0].id).to eq 'outer_first'
96
+ expect(browser.table(id: 'inner')[0].id).to eq 'inner_first'
97
+ expect(browser.table(id: 'outer')[2].id).to eq 'outer_last'
98
98
  end
99
99
  end
100
100
 
101
- describe "#row" do
101
+ describe '#row' do
102
102
  let(:table) { browser.table(id: 'outer') }
103
103
 
104
- it "finds rows belonging to this table" do
105
- expect(table.row(id: "outer_last")).to exist
104
+ it 'finds rows belonging to this table' do
105
+ expect(table.row(id: 'outer_last')).to exist
106
106
  expect(table.row(text: /Table 1, Row 1, Cell 1/)).to exist
107
107
  end
108
108
 
109
- it "does not find rows from a nested table" do
110
- expect(table.row(id: "inner_first")).to_not exist
109
+ it 'does not find rows from a nested table' do
110
+ expect(table.row(id: 'inner_first')).to_not exist
111
111
  expect(table.row(text: /\ATable 2, Row 1, Cell 1 Table 2, Row 1, Cell 2\z/)).to_not exist
112
112
  end
113
113
  end
114
114
 
115
- describe "#rows" do
116
- it "finds the correct number of rows (excluding nested tables)" do
115
+ describe '#rows' do
116
+ it 'finds the correct number of rows (excluding nested tables)' do
117
117
  expect(browser.table(id: 'inner').rows.length).to eq 1
118
118
  expect(browser.table(id: 'outer').rows.length).to eq 3
119
119
  end
120
120
 
121
- it "finds rows matching the selector" do
121
+ it 'finds rows matching the selector' do
122
122
  rows = browser.table(id: 'outer').rows(id: /first|last/)
123
123
 
124
- expect(rows.first.id).to eq "outer_first"
125
- expect(rows.last.id).to eq "outer_last"
124
+ expect(rows.first.id).to eq 'outer_first'
125
+ expect(rows.last.id).to eq 'outer_last'
126
126
  end
127
127
 
128
- it "does not find rows from a nested table" do
129
- expect(browser.table(id: "outer").rows(id: "t2_r1_c1").size).to eq 0
128
+ it 'does not find rows from a nested table' do
129
+ expect(browser.table(id: 'outer').rows(id: 't2_r1_c1').size).to eq 0
130
130
  end
131
131
  end
132
132
 
133
- describe "#tbody" do
134
- it "returns the correct instance of TableSection" do
133
+ describe '#tbody' do
134
+ it 'returns the correct instance of TableSection' do
135
135
  body = browser.table(index: 0).tbody(id: 'first')
136
136
  expect(body).to be_instance_of(Watir::TableSection)
137
- expect(body[0][0].text).to eq "March 2008"
137
+ expect(body[0][0].text).to eq 'March 2008'
138
138
  end
139
139
  end
140
140
 
141
- describe "#tbodys" do
142
- it "returns the correct instance of TableSection" do
141
+ describe '#tbodys' do
142
+ it 'returns the correct instance of TableSection' do
143
143
  bodies = browser.table(index: 0).tbodys
144
144
 
145
145
  expect(bodies).to be_instance_of(Watir::TableSectionCollection)
146
146
 
147
- expect(bodies[0].id).to eq "first"
148
- expect(bodies[1].id).to eq "second"
147
+ expect(bodies[0].id).to eq 'first'
148
+ expect(bodies[1].id).to eq 'second'
149
149
  end
150
150
  end
151
-
152
151
  end
@@ -1,33 +1,32 @@
1
- require "watirspec_helper"
2
-
3
- describe "Tables" do
1
+ require 'watirspec_helper'
4
2
 
3
+ describe 'Tables' do
5
4
  before :each do
6
- browser.goto(WatirSpec.url_for("tables.html"))
5
+ browser.goto(WatirSpec.url_for('tables.html'))
7
6
  end
8
7
 
9
- describe "with selectors" do
10
- it "returns the matching elements" do
11
- expect(browser.tables(rules: "groups").to_a).to eq [browser.table(rules: "groups")]
8
+ describe 'with selectors' do
9
+ it 'returns the matching elements' do
10
+ expect(browser.tables(rules: 'groups').to_a).to eq [browser.table(rules: 'groups')]
12
11
  end
13
12
  end
14
13
 
15
- describe "#length" do
16
- it "returns the number of tables" do
14
+ describe '#length' do
15
+ it 'returns the number of tables' do
17
16
  expect(browser.tables.length).to eq 4
18
17
  end
19
18
  end
20
19
 
21
- describe "#[]" do
22
- it "returns the p at the given index" do
23
- expect(browser.tables[0].id).to eq "axis_example"
24
- expect(browser.tables[1].id).to eq "outer"
25
- expect(browser.tables[2].id).to eq "inner"
20
+ describe '#[]' do
21
+ it 'returns the p at the given index' do
22
+ expect(browser.tables[0].id).to eq 'axis_example'
23
+ expect(browser.tables[1].id).to eq 'outer'
24
+ expect(browser.tables[2].id).to eq 'inner'
26
25
  end
27
26
  end
28
27
 
29
- describe "#each" do
30
- it "iterates through tables correctly" do
28
+ describe '#each' do
29
+ it 'iterates through tables correctly' do
31
30
  count = 0
32
31
 
33
32
  browser.tables.each_with_index do |t, index|
@@ -38,5 +37,4 @@ describe "Tables" do
38
37
  expect(count).to be > 0
39
38
  end
40
39
  end
41
-
42
40
  end
@@ -1,27 +1,26 @@
1
- require "watirspec_helper"
2
-
3
- describe "TableBody" do
1
+ require 'watirspec_helper'
4
2
 
3
+ describe 'TableBody' do
5
4
  before :each do
6
- browser.goto(WatirSpec.url_for("tables.html"))
5
+ browser.goto(WatirSpec.url_for('tables.html'))
7
6
  end
8
7
 
9
- describe "#exists?" do
10
- it "returns true if the table body exists (page context)" do
8
+ describe '#exists?' do
9
+ it 'returns true if the table body exists (page context)' do
11
10
  expect(browser.tbody(id: 'first')).to exist
12
11
  expect(browser.tbody(id: /first/)).to exist
13
12
  expect(browser.tbody(index: 0)).to exist
14
13
  expect(browser.tbody(xpath: "//tbody[@id='first']")).to exist
15
14
  end
16
15
 
17
- it "returns true if the table body exists (table context)" do
16
+ it 'returns true if the table body exists (table context)' do
18
17
  expect(browser.table(index: 0).tbody(id: 'first')).to exist
19
18
  expect(browser.table(index: 0).tbody(id: /first/)).to exist
20
19
  expect(browser.table(index: 0).tbody(index: 1)).to exist
21
20
  expect(browser.table(index: 0).tbody(xpath: "//tbody[@id='first']")).to exist
22
21
  end
23
22
 
24
- it "returns the first table body if given no args" do
23
+ it 'returns the first table body if given no args' do
25
24
  expect(browser.table.tbody).to exist
26
25
  end
27
26
 
@@ -45,15 +44,15 @@ describe "TableBody" do
45
44
  end
46
45
  end
47
46
 
48
- bug "Safari does not strip text", :safari do
49
- describe "#[]" do
50
- it "returns the row at the given index (page context)" do
47
+ bug 'Safari does not strip text', :safari do
48
+ describe '#[]' do
49
+ it 'returns the row at the given index (page context)' do
51
50
  expect(browser.tbody(id: 'first')[0].text).to eq 'March 2008'
52
51
  expect(browser.tbody(id: 'first')[1][0].text).to eq 'Gregory House'
53
52
  expect(browser.tbody(id: 'first')[2][0].text).to eq 'Hugh Laurie'
54
53
  end
55
54
 
56
- it "returns the row at the given index (table context)" do
55
+ it 'returns the row at the given index (table context)' do
57
56
  expect(browser.table(index: 0).tbody(id: 'first')[0].text).to eq 'March 2008'
58
57
  expect(browser.table(index: 0).tbody(id: 'first')[1][0].text).to eq 'Gregory House'
59
58
  expect(browser.table(index: 0).tbody(id: 'first')[2][0].text).to eq 'Hugh Laurie'
@@ -61,32 +60,32 @@ describe "TableBody" do
61
60
  end
62
61
  end
63
62
 
64
- describe "#row" do
65
- it "finds the first row matching the selector" do
66
- row = browser.tbody(id: 'first').row(id: "gregory")
63
+ describe '#row' do
64
+ it 'finds the first row matching the selector' do
65
+ row = browser.tbody(id: 'first').row(id: 'gregory')
67
66
 
68
- expect(row.tag_name).to eq "tr"
69
- expect(row.id).to eq "gregory"
67
+ expect(row.tag_name).to eq 'tr'
68
+ expect(row.id).to eq 'gregory'
70
69
  end
71
70
  end
72
71
 
73
- describe "#rows" do
74
- it "finds rows matching the selector" do
72
+ describe '#rows' do
73
+ it 'finds rows matching the selector' do
75
74
  rows = browser.tbody(id: 'first').rows(id: /h$/)
76
75
 
77
76
  expect(rows.size).to eq 2
78
77
 
79
- expect(rows.first.id).to eq "march"
80
- expect(rows.last.id).to eq "hugh"
78
+ expect(rows.first.id).to eq 'march'
79
+ expect(rows.last.id).to eq 'hugh'
81
80
  end
82
81
  end
83
82
 
84
- describe "#strings" do
85
- it "returns the text of child cells" do
83
+ describe '#strings' do
84
+ it 'returns the text of child cells' do
86
85
  expect(browser.tbody(id: 'first').strings).to eq [
87
- ["March 2008", "", "", ""],
88
- ["Gregory House", "5 934", "1 347", "4 587"],
89
- ["Hugh Laurie", "6 300", "1 479", "4 821"]
86
+ ['March 2008', '', '', ''],
87
+ ['Gregory House', '5 934', '1 347', '4 587'],
88
+ ['Hugh Laurie', '6 300', '1 479', '4 821']
90
89
  ]
91
90
  end
92
91
  end
@@ -1,39 +1,38 @@
1
- require "watirspec_helper"
2
-
3
- describe "TableBodies" do
1
+ require 'watirspec_helper'
4
2
 
3
+ describe 'TableBodies' do
5
4
  before :each do
6
- browser.goto(WatirSpec.url_for("tables.html"))
5
+ browser.goto(WatirSpec.url_for('tables.html'))
7
6
  end
8
7
 
9
- describe "with selectors" do
10
- it "returns the matching elements" do
11
- expect(browser.tbodys(id: "first").to_a).to eq [browser.tbody(id: "first")]
8
+ describe 'with selectors' do
9
+ it 'returns the matching elements' do
10
+ expect(browser.tbodys(id: 'first').to_a).to eq [browser.tbody(id: 'first')]
12
11
  end
13
12
  end
14
13
 
15
- describe "#length" do
16
- it "returns the correct number of table bodies (page context)" do
14
+ describe '#length' do
15
+ it 'returns the correct number of table bodies (page context)' do
17
16
  expect(browser.tbodys.length).to eq 5
18
17
  end
19
18
 
20
- it "returns the correct number of table bodies (table context)" do
19
+ it 'returns the correct number of table bodies (table context)' do
21
20
  expect(browser.table(index: 0).tbodys.length).to eq 2
22
21
  end
23
22
  end
24
23
 
25
- describe "#[]" do
26
- it "returns the row at the given index (page context)" do
27
- expect(browser.tbodys[0].id).to eq "first"
24
+ describe '#[]' do
25
+ it 'returns the row at the given index (page context)' do
26
+ expect(browser.tbodys[0].id).to eq 'first'
28
27
  end
29
28
 
30
- it "returns the row at the given index (table context)" do
31
- expect(browser.table(index: 0).tbodys[0].id).to eq "first"
29
+ it 'returns the row at the given index (table context)' do
30
+ expect(browser.table(index: 0).tbodys[0].id).to eq 'first'
32
31
  end
33
32
  end
34
33
 
35
- describe "#each" do
36
- it "iterates through table bodies correctly (table context)" do
34
+ describe '#each' do
35
+ it 'iterates through table bodies correctly (table context)' do
37
36
  count = 0
38
37
 
39
38
  browser.tbodys.each_with_index do |body, index|
@@ -45,7 +44,7 @@ describe "TableBodies" do
45
44
  expect(count).to be > 0
46
45
  end
47
46
 
48
- it "iterates through table bodies correctly (table context)" do
47
+ it 'iterates through table bodies correctly (table context)' do
49
48
  table = browser.table(index: 0)
50
49
  count = 0
51
50
 
@@ -58,5 +57,4 @@ describe "TableBodies" do
58
57
  expect(count).to be > 0
59
58
  end
60
59
  end
61
-
62
60
  end
@@ -1,14 +1,13 @@
1
- require "watirspec_helper"
2
-
3
- describe "TableCell" do
1
+ require 'watirspec_helper'
4
2
 
3
+ describe 'TableCell' do
5
4
  before :each do
6
- browser.goto(WatirSpec.url_for("tables.html"))
5
+ browser.goto(WatirSpec.url_for('tables.html'))
7
6
  end
8
7
 
9
8
  # Exists
10
- describe "#exists?" do
11
- it "returns true when the table cell exists" do
9
+ describe '#exists?' do
10
+ it 'returns true when the table cell exists' do
12
11
  expect(browser.td(id: 't1_r2_c1')).to exist
13
12
  expect(browser.td(id: /t1_r2_c1/)).to exist
14
13
  expect(browser.td(text: 'Table 1, Row 3, Cell 1')).to exist
@@ -17,11 +16,11 @@ describe "TableCell" do
17
16
  expect(browser.td(xpath: "//td[@id='t1_r2_c1']")).to exist
18
17
  end
19
18
 
20
- it "returns the first cell if given no args" do
19
+ it 'returns the first cell if given no args' do
21
20
  expect(browser.td).to exist
22
21
  end
23
22
 
24
- it "returns false when the table cell does not exist" do
23
+ it 'returns false when the table cell does not exist' do
25
24
  expect(browser.td(id: 'no_such_id')).to_not exist
26
25
  expect(browser.td(id: /no_such_id/)).to_not exist
27
26
  expect(browser.td(text: 'no_such_text')).to_not exist
@@ -35,7 +34,7 @@ describe "TableCell" do
35
34
  end
36
35
  end
37
36
 
38
- describe "#click" do
37
+ describe '#click' do
39
38
  it "fires the table's onclick event" do
40
39
  browser.td(id: 't2_r1_c1').click
41
40
  expect(messages).to include('td')
@@ -43,50 +42,49 @@ describe "TableCell" do
43
42
  end
44
43
 
45
44
  # Attribute methods
46
- bug "Safari does not strip text", :safari do
47
- describe "#text" do
48
- it "returns the text inside the table cell" do
45
+ bug 'Safari does not strip text', :safari do
46
+ describe '#text' do
47
+ it 'returns the text inside the table cell' do
49
48
  expect(browser.td(id: 't1_r2_c1').text).to eq 'Table 1, Row 2, Cell 1'
50
49
  expect(browser.td(id: 't2_r1_c1').text).to eq 'Table 2, Row 1, Cell 1'
51
50
  end
52
51
  end
53
52
  end
54
53
 
55
- describe "#colspan" do
56
- it "gets the colspan attribute" do
54
+ describe '#colspan' do
55
+ it 'gets the colspan attribute' do
57
56
  expect(browser.td(id: 'colspan_2').colspan).to eq 2
58
57
  expect(browser.td(id: 'no_colspan').colspan).to eq 1
59
58
  end
60
59
  end
61
60
 
62
- describe "#respond_to?" do
63
- it "returns true for all attribute methods" do
61
+ describe '#respond_to?' do
62
+ it 'returns true for all attribute methods' do
64
63
  expect(browser.td(index: 0)).to respond_to(:text)
65
64
  expect(browser.td(index: 0)).to respond_to(:colspan)
66
65
  end
67
66
  end
68
67
 
69
- describe "#column_header" do
70
- it "returns the corresponding column header" do
68
+ describe '#column_header' do
69
+ it 'returns the corresponding column header' do
71
70
  header = browser.td(text: '1 331').column_header
72
71
  expect(header).to eq 'Income tax'
73
72
  end
74
73
  end
75
74
 
76
- describe "#sibling_from_header" do
77
- it "returns the corresponding sibling cell by text" do
75
+ describe '#sibling_from_header' do
76
+ it 'returns the corresponding sibling cell by text' do
78
77
  local_td = browser.td(text: '1 331')
79
78
 
80
79
  td = local_td.sibling_from_header(text: 'After income tax')
81
80
  expect(td.text).to eq '4 532'
82
81
  end
83
82
 
84
- it "returns the corresponding sibling cell by index" do
83
+ it 'returns the corresponding sibling cell by index' do
85
84
  local_td = browser.td(text: '1 331')
86
85
 
87
86
  td = local_td.sibling_from_header(text: /tax/, index: 2)
88
87
  expect(td.text).to eq '4 532'
89
88
  end
90
-
91
89
  end
92
90
  end