druid-ts 1.2.4 → 1.2.5

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +21 -2
  3. data/Gemfile +1 -1
  4. data/druid.gemspec +3 -3
  5. data/features/element.feature +0 -5
  6. data/features/frames.feature +4 -0
  7. data/features/html/static_elements.html +11 -0
  8. data/features/populate_page_with.feature +25 -0
  9. data/features/select_list.feature +1 -0
  10. data/features/step_definations/audio_steps.rb +1 -1
  11. data/features/step_definations/element_steps.rb +0 -4
  12. data/features/step_definations/frame_steps.rb +35 -0
  13. data/features/step_definations/populate_page_with_steps.rb +3 -0
  14. data/features/step_definations/select_list_steps.rb +4 -0
  15. data/features/step_definations/table_steps.rb +19 -0
  16. data/features/support/page.rb +2 -0
  17. data/features/table.feature +21 -0
  18. data/lib/druid.rb +0 -1
  19. data/lib/druid/assist.rb +8 -5
  20. data/lib/druid/elements/area.rb +0 -20
  21. data/lib/druid/elements/check_box.rb +0 -20
  22. data/lib/druid/elements/element.rb +73 -64
  23. data/lib/druid/elements/file_field.rb +0 -6
  24. data/lib/druid/elements/hidden_field.rb +0 -4
  25. data/lib/druid/elements/image.rb +0 -7
  26. data/lib/druid/elements/media.rb +0 -34
  27. data/lib/druid/elements/ordered_list.rb +8 -21
  28. data/lib/druid/elements/radio_button.rb +0 -13
  29. data/lib/druid/elements/select_list.rb +2 -11
  30. data/lib/druid/elements/table.rb +41 -16
  31. data/lib/druid/elements/table_row.rb +21 -17
  32. data/lib/druid/elements/text_area.rb +0 -7
  33. data/lib/druid/elements/text_field.rb +0 -7
  34. data/lib/druid/elements/unordered_list.rb +9 -22
  35. data/lib/druid/javascript_framework_facade.rb +1 -1
  36. data/lib/druid/locator_generator.rb +153 -147
  37. data/lib/druid/page_populator.rb +44 -37
  38. data/lib/druid/version.rb +1 -1
  39. data/spec/druid/accessors_spec.rb +3 -3
  40. data/spec/druid/elements/check_box_spec.rb +0 -15
  41. data/spec/druid/elements/element_spec.rb +77 -78
  42. data/spec/druid/elements/file_field_spec.rb +0 -5
  43. data/spec/druid/elements/media_spec.rb +0 -49
  44. data/spec/druid/elements/ordered_list_spec.rb +24 -20
  45. data/spec/druid/elements/radio_button_spec.rb +0 -10
  46. data/spec/druid/elements/table_row_spec.rb +12 -12
  47. data/spec/druid/elements/table_spec.rb +29 -25
  48. data/spec/druid/elements/text_area_spec.rb +0 -4
  49. data/spec/druid/elements/text_field_spec.rb +0 -5
  50. data/spec/druid/elements/unordered_list_spec.rb +25 -20
  51. data/spec/druid/javascript_framework_facade_spec.rb +1 -1
  52. data/spec/druid/page_populator_spec.rb +34 -4
  53. metadata +15 -18
  54. data/lib/druid/core_ext/string.rb +0 -5
  55. data/spec/druid/elements/area_spec.rb +0 -25
  56. data/spec/druid/elements/canvas_spec.rb +0 -19
  57. data/spec/druid/elements/video_spec.rb +0 -25
@@ -2,33 +2,37 @@ require 'spec_helper'
2
2
  require 'druid/elements'
3
3
 
4
4
  describe Druid::Elements::OrderedList do
5
+ let(:ol) { Druid::Elements::OrderedList }
6
+
5
7
  describe "interface" do
6
- let(:element) { double 'element' }
7
- let(:ol) { Druid::Elements::OrderedList.new(element) }
8
+ let(:ol_element) { double('ol_element').as_null_object }
9
+ let(:li_element) { double('li_element') }
8
10
 
9
- it "should return a list item when indexed" do
10
- allow(element).to receive(:ols).and_return(element)
11
- expect(element).to receive(:[])
12
- ol[1]
11
+ it "should register as tag_name :ol" do
12
+ expect(Druid::Elements.element_class_for(:ol)).to be Druid::Elements::OrderedList
13
13
  end
14
14
 
15
- it "should know how many list items it contains" do
16
- allow(element).to receive(:ols).and_return([element])
17
- expect(ol.items).to eql 1
18
- end
15
+ context "for sub methods" do
16
+ before(:each) do
17
+ allow(ol_element).to receive(:tag_name).and_return(:ol)
18
+ end
19
+ let(:ol) { ol = Druid::Elements::OrderedList.new(ol_element) }
19
20
 
20
- it "should iterate over the list items" do
21
- expect(ol).to receive(:items).and_return(2)
22
- allow(ol).to receive(:[])
23
- count = 0
24
- ol.each do
25
- count += 1
21
+ it "should return a list item when indexed" do
22
+ allow(ol_element).to receive(:children).and_return([ol_element, ol_element])
23
+ ol[1]
26
24
  end
27
- expect(count).to eql 2
28
- end
29
25
 
30
- it "should register as tag_name :ol" do
31
- expect(Druid::Elements.element_class_for(:ol)).to be Druid::Elements::OrderedList
26
+ it "should know how many list items it contains" do
27
+ allow(ol_element).to receive(:children).and_return([ol_element])
28
+ expect(ol.items).to eql 1
29
+ end
30
+
31
+ it "should iterate over the list items" do
32
+ expect(ol).to receive(:list_items).and_return(Array.new(5, ol_element))
33
+ expect(ol.items).to eql 5
34
+ end
32
35
  end
36
+
33
37
  end
34
38
  end
@@ -7,16 +7,6 @@ describe Druid::Elements::RadioButton do
7
7
  let(:driver) { double("driver") }
8
8
  let(:radio) { Druid::Elements::RadioButton.new(element)}
9
9
 
10
- it "should select" do
11
- expect(element).to receive(:set)
12
- radio.select
13
- end
14
-
15
- it "should know if it is selected" do
16
- expect(element).to receive(:set?)
17
- radio.selected?
18
- end
19
-
20
10
  it "should register as type :radio" do
21
11
  expect(Druid::Elements.element_class_for(:input, :radio)).to be Druid::Elements::RadioButton
22
12
  end
@@ -2,29 +2,29 @@ require 'spec_helper'
2
2
  require 'druid/elements'
3
3
 
4
4
  describe Druid::Elements::TableRow do
5
+ let(:table_cell) { double('table_cell') }
6
+ let(:element) { double 'element' }
7
+ let(:table_row) { Druid::Elements::TableRow.new(element) }
8
+
5
9
  describe "interface" do
6
- let(:element) { double 'element' }
7
- let(:table_row) { Druid::Elements::TableRow.new(element) }
10
+
11
+ before(:each) do
12
+ allow(element).to receive(:find_elements).and_return(element)
13
+ allow(element).to receive(:cells).and_return(Array.new(2, Watir::TableCell))
14
+ end
8
15
 
9
16
  it "should return a table cell when indexed" do
10
- allow(table_row).to receive(:columns).and_return(2)
11
- expect(element).to receive(:[]).with(1)
12
17
  expect(table_row[1]).to be_instance_of Druid::Elements::TableCell
13
18
  end
14
19
 
15
20
  it "should return the number of columns" do
16
- expect(element).to receive_message_chain(:cells, :size).and_return(3)
17
- expect(table_row.columns).to eql 3
21
+ expect(table_row.columns).to eql 2
18
22
  end
19
23
 
20
24
  it "should iterate over the table columns" do
21
- expect(table_row).to receive(:columns).and_return(3)
22
- allow(table_row).to receive(:[])
23
25
  count = 0
24
- table_row.each do
25
- count += 1
26
- end
27
- expect(count).to eql 3
26
+ table_row.each{ count += 1}
27
+ expect(count).to eql 2
28
28
  end
29
29
 
30
30
  it "should register with tag_name :tr" do
@@ -4,40 +4,44 @@ require 'druid/elements'
4
4
  describe Druid::Elements::Table do
5
5
  describe "interface" do
6
6
  let(:element) { double('element')}
7
- let(:table) { Druid::Elements::Table.new(element) }
8
7
 
9
- it "should return a table row" do
10
- expect(element).to receive(:[]).with(1)
11
- expect(table[1]).to be_instance_of Druid::Elements::TableRow
8
+ before(:each) do
9
+ allow(element).to receive(:rows).and_return(Array.new(2, Watir::TableRow))
12
10
  end
13
11
 
14
- it "should return the number of rows" do
15
- expect(element).to receive_message_chain(:rows, :size).and_return(2)
16
- expect(table.rows).to eql 2
12
+ it "should register with tag_name :table" do
13
+ expect(Druid::Elements.element_class_for(:table)).to eql Druid::Elements::Table
17
14
  end
18
15
 
19
- it "should iterate over the table rows" do
20
- allow(element).to receive(:[])
21
- expect(table).to receive(:rows).and_return(2)
22
- count = 0
23
- table.each do
24
- count += 1
16
+ context "for sub methods" do
17
+
18
+ let(:table) { Druid::Elements::Table.new(element) }
19
+
20
+ it "should return a table row" do
21
+ expect(table[1]).to be_instance_of Druid::Elements::TableRow
25
22
  end
26
- expect(count).to eql 2
27
- end
28
23
 
29
- it "should return the first row" do
30
- expect(element).to receive(:[]).with(0).and_return(element)
31
- expect(table.first_row).to be_instance_of Druid::Elements::TableRow
32
- end
24
+ it "should return the number of rows" do
25
+ expect(table.rows).to eql 2
26
+ end
33
27
 
34
- it "should return the last row" do
35
- expect(element).to receive(:[]).with(-1).and_return(element)
36
- expect(table.last_row).to be_instance_of Druid::Elements::TableRow
37
- end
28
+ it "should iterate over the table rows" do
29
+ count = 0
30
+ table.each do
31
+ count += 1
32
+ end
33
+ expect(count).to eql 2
34
+ end
35
+
36
+ it "should return the first row" do
37
+ expect(table.first_row).to be_instance_of Druid::Elements::TableRow
38
+ end
39
+
40
+ it "should return the last row" do
41
+ expect(table.last_row).to be_instance_of Druid::Elements::TableRow
42
+ end
38
43
 
39
- it "should register with tag_name :table" do
40
- expect(Druid::Elements.element_class_for(:table)).to be Druid::Elements::Table
41
44
  end
45
+
42
46
  end
43
47
  end
@@ -5,10 +5,6 @@ describe Druid::Elements::TextArea do
5
5
  describe "interface" do
6
6
  let(:element) { double "element" }
7
7
  let(:text_area) { Druid::Elements::TextArea.new(element) }
8
- it "should set its' value" do
9
- expect(element).to receive(:set).with('test')
10
- text_area.value = 'test'
11
- end
12
8
 
13
9
  it "should register with tag_name :textarea" do
14
10
  expect(Druid::Elements.element_class_for(:textarea)).to be Druid::Elements::TextArea
@@ -6,11 +6,6 @@ describe Druid::Elements::TextField do
6
6
  let(:element) { double 'element' }
7
7
  let(:text_field) { Druid::Elements::TextField.new(element) }
8
8
 
9
- it "should set its' value" do
10
- expect(element).to receive(:set).with('test')
11
- text_field.value = 'test'
12
- end
13
-
14
9
  it "should register with type :text" do
15
10
  expect(Druid::Elements.element_class_for(:input, :text)).to be Druid::Elements::TextField
16
11
  end
@@ -2,33 +2,38 @@ require 'spec_helper'
2
2
  require 'druid/elements'
3
3
 
4
4
  describe Druid::Elements::UnOrderedList do
5
+ let(:ul) { Druid::Elements::UnOrderedList.new(ul_element) }
6
+
5
7
  describe "interface" do
6
- let(:element) { double 'element' }
7
- let(:ul) { Druid::Elements::UnOrderedList.new(element) }
8
+ let(:ul_element) { double('ul_element').as_null_object }
9
+ let(:li_element) { double('li_element').as_null_object }
8
10
 
9
- it "should return a list item when indexed" do
10
- allow(element).to receive(:uls).and_return(element)
11
- expect(element).to receive(:[])
12
- ul[1]
11
+ it "should register with tag_name :ul" do
12
+ expect(Druid::Elements.element_class_for(:ul)).to be Druid::Elements::UnOrderedList
13
13
  end
14
14
 
15
- it "should know how many items it contains" do
16
- allow(element).to receive(:uls).and_return([element])
17
- expect(ul.items).to eql 1
18
- end
15
+ context "for sub method" do
16
+ before(:each) do
17
+ allow(ul_element).to receive(:children).and_return([li_element, li_element])
18
+ allow(li_element).to receive(:tag_name).and_return(:li)
19
+ end
19
20
 
20
- it "should know how to iterate over the items" do
21
- expect(ul).to receive(:items).and_return(3)
22
- allow(ul).to receive(:[])
23
- count = 0
24
- ul.each do
25
- count += 1
21
+ it "should return a list item when indexed" do
22
+ expect(ul[1]).to be_instance_of Druid::Elements::ListItem
26
23
  end
27
- expect(count).to eql 3
28
- end
29
24
 
30
- it "should register with tag_name :ul" do
31
- expect(Druid::Elements.element_class_for(:ul)).to be Druid::Elements::UnOrderedList
25
+ it "should know how many items it contains" do
26
+ expect(ul.items).to eql 2
27
+ end
28
+
29
+ it "should know how to iterate over the items" do
30
+ count = 0
31
+ ul.each { count += 1 }
32
+ expect(count).to eql 2
33
+ end
32
34
  end
35
+
36
+
37
+
33
38
  end
34
39
  end
@@ -34,7 +34,7 @@ describe Druid::JavascriptFrameworkFacade do
34
34
  end
35
35
 
36
36
  it "should not allow you to set the framework to one it does not know about" do
37
- expect{ facade.framework = :blah }.to raise_error "You specified the Javascript framework blah and it is unknow to the system"
37
+ expect{ facade.framework = :blah }.to raise_error "You specified the Javascript framework blah and it is unknown to the system"
38
38
  end
39
39
 
40
40
  it "should allow you to add a new javascript framework" do
@@ -1,5 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
+ class Section
4
+ include Druid
5
+
6
+ text_field(:stf, id: 'id')
7
+ end
8
+
3
9
  class DruidPagePopulator
4
10
  include Druid
5
11
 
@@ -10,6 +16,7 @@ class DruidPagePopulator
10
16
  radio_button(:rb, :id => 'id')
11
17
  file_field(:ff, :id => 'id')
12
18
  radio_button_group(:rbg, :id => 'id')
19
+ page_section(:section, Section, id: 'foo')
13
20
  end
14
21
 
15
22
  describe Druid::PagePopulator do
@@ -44,10 +51,7 @@ describe Druid::PagePopulator do
44
51
  end
45
52
 
46
53
  it "should set a value in a select list" do
47
- list = double('sl')
48
- expect(druid).to receive(:sl_element).and_return(list)
49
- expect(list).to receive(:options).and_return(['value'])
50
- expect(list).to receive(:select).with('value')
54
+ expect(druid).to receive(:sl=).with('value')
51
55
  druid.populate_page_with('sl' => 'value')
52
56
  end
53
57
 
@@ -122,4 +126,30 @@ describe Druid::PagePopulator do
122
126
  druid.populate_page_with('rb' => true)
123
127
  end
124
128
 
129
+ context "when using a nested for a section" do
130
+ let(:section) { double('section') }
131
+
132
+ before do
133
+ allow(druid).to receive(:section).and_return section
134
+ end
135
+
136
+ it "should populate a page section when the value is a hash and it exists" do
137
+ expect(section).to receive(:stf=).with('value')
138
+ expect(druid).to receive(:is_enabled?).and_return(true)
139
+ druid.populate_page_with('section' => {'stf' => 'value'})
140
+ end
141
+
142
+ it "should not set a value in a text field if it is not found on the page" do
143
+ expect(section).not_to receive(:text_field)
144
+ druid.populate_page_with('section' => {'coffee' => 'value'})
145
+ end
146
+
147
+ it "should not populate a text field when it is disabled" do
148
+ expect(section).not_to receive(:stf=)
149
+ expect(section).to receive(:stf_element).twice.and_return(driver)
150
+ expect(driver).to receive(:enabled?).and_return(false)
151
+ expect(driver).to receive(:tag_name).and_return('input')
152
+ druid.populate_page_with('section' => {'stf' => true})
153
+ end
154
+ end
125
155
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: druid-ts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Sheng
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '6.0'
19
+ version: '6.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '6.0'
26
+ version: '6.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: page_navigation
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -42,30 +42,30 @@ dependencies:
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 3.0.0
47
+ version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 3.0.0
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: cucumber
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.0.0
61
+ version: '2.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 2.0.0
68
+ version: '2.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rack
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -161,6 +161,7 @@ files:
161
161
  - features/ordered_list.feature
162
162
  - features/page_level_actions.feature
163
163
  - features/paragraph.feature
164
+ - features/populate_page_with.feature
164
165
  - features/radio_button.feature
165
166
  - features/radio_button_group.feature
166
167
  - features/sample-app/public/04-Death_Becomes_Fur.mp4
@@ -204,6 +205,7 @@ files:
204
205
  - features/step_definations/page_level_actions_steps.rb
205
206
  - features/step_definations/page_traversal_steps.rb
206
207
  - features/step_definations/paragraph_steps.rb
208
+ - features/step_definations/populate_page_with_steps.rb
207
209
  - features/step_definations/radio_button_group_steps.rb
208
210
  - features/step_definations/radio_button_steps.rb
209
211
  - features/step_definations/section_steps.rb
@@ -235,7 +237,6 @@ files:
235
237
  - lib/druid.rb
236
238
  - lib/druid/accessors.rb
237
239
  - lib/druid/assist.rb
238
- - lib/druid/core_ext/string.rb
239
240
  - lib/druid/element_locators.rb
240
241
  - lib/druid/elements.rb
241
242
  - lib/druid/elements/area.rb
@@ -283,10 +284,8 @@ files:
283
284
  - spec/druid/accessors_spec.rb
284
285
  - spec/druid/druid_spec.rb
285
286
  - spec/druid/element_locators_spec.rb
286
- - spec/druid/elements/area_spec.rb
287
287
  - spec/druid/elements/bold_spec.rb
288
288
  - spec/druid/elements/button_spec.rb
289
- - spec/druid/elements/canvas_spec.rb
290
289
  - spec/druid/elements/check_box_spec.rb
291
290
  - spec/druid/elements/div_spec.rb
292
291
  - spec/druid/elements/element_spec.rb
@@ -313,7 +312,6 @@ files:
313
312
  - spec/druid/elements/text_area_spec.rb
314
313
  - spec/druid/elements/text_field_spec.rb
315
314
  - spec/druid/elements/unordered_list_spec.rb
316
- - spec/druid/elements/video_spec.rb
317
315
  - spec/druid/javascript_framework_facade_spec.rb
318
316
  - spec/druid/nested_element_spec.rb
319
317
  - spec/druid/page_factory_spec.rb
@@ -395,6 +393,7 @@ test_files:
395
393
  - features/ordered_list.feature
396
394
  - features/page_level_actions.feature
397
395
  - features/paragraph.feature
396
+ - features/populate_page_with.feature
398
397
  - features/radio_button.feature
399
398
  - features/radio_button_group.feature
400
399
  - features/sample-app/public/04-Death_Becomes_Fur.mp4
@@ -438,6 +437,7 @@ test_files:
438
437
  - features/step_definations/page_level_actions_steps.rb
439
438
  - features/step_definations/page_traversal_steps.rb
440
439
  - features/step_definations/paragraph_steps.rb
440
+ - features/step_definations/populate_page_with_steps.rb
441
441
  - features/step_definations/radio_button_group_steps.rb
442
442
  - features/step_definations/radio_button_steps.rb
443
443
  - features/step_definations/section_steps.rb
@@ -469,10 +469,8 @@ test_files:
469
469
  - spec/druid/accessors_spec.rb
470
470
  - spec/druid/druid_spec.rb
471
471
  - spec/druid/element_locators_spec.rb
472
- - spec/druid/elements/area_spec.rb
473
472
  - spec/druid/elements/bold_spec.rb
474
473
  - spec/druid/elements/button_spec.rb
475
- - spec/druid/elements/canvas_spec.rb
476
474
  - spec/druid/elements/check_box_spec.rb
477
475
  - spec/druid/elements/div_spec.rb
478
476
  - spec/druid/elements/element_spec.rb
@@ -499,7 +497,6 @@ test_files:
499
497
  - spec/druid/elements/text_area_spec.rb
500
498
  - spec/druid/elements/text_field_spec.rb
501
499
  - spec/druid/elements/unordered_list_spec.rb
502
- - spec/druid/elements/video_spec.rb
503
500
  - spec/druid/javascript_framework_facade_spec.rb
504
501
  - spec/druid/nested_element_spec.rb
505
502
  - spec/druid/page_factory_spec.rb