druid-ts 1.1.0 → 1.1.1

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.
@@ -0,0 +1,98 @@
1
+ require 'spec_helper'
2
+ require 'druid/page_factory'
3
+
4
+ class FactoryTestDruid
5
+ include Druid
6
+ page_url "http://google.com"
7
+ end
8
+
9
+ class AnotherPage
10
+ include Druid
11
+ end
12
+
13
+ class YetAnotherPage
14
+ include Druid
15
+ end
16
+
17
+ class TestWorld
18
+ include Druid::PageFactory
19
+
20
+ attr_accessor :driver
21
+ attr_accessor :current_page
22
+ end
23
+
24
+
25
+ describe Druid::PageFactory do
26
+
27
+ let(:world) { TestWorld.new }
28
+ let(:driver) do
29
+ world.driver = mock_driver
30
+ driver = world.driver
31
+ end
32
+
33
+ it "should create a new page object and execute a block" do
34
+ expect(driver).not_to receive(:goto)
35
+ world.on_page FactoryTestDruid do |page|
36
+ expect(page).to be_instance_of FactoryTestDruid
37
+ end
38
+ end
39
+
40
+ it "should create and visit a new page" do
41
+ expect(driver).to receive(:goto)
42
+ world.visit_page FactoryTestDruid do |page|
43
+ expect(page).to be_instance_of FactoryTestDruid
44
+ end
45
+ end
46
+
47
+ it "should set an instance variable that can be used outside of the block" do
48
+ expect(driver).not_to receive(:goto)
49
+ page = world.on_page FactoryTestDruid
50
+ current_page = world.instance_variable_get "@current_page"
51
+ expect(current_page).to be page
52
+ end
53
+
54
+ it "should raise an error when you do not provide a default route" do
55
+ expect { Druid::PageFactory.routes = {:another => []} }.to raise_error 'You must provide a :default route for PageFactory routes'
56
+ end
57
+
58
+ it "should store the routes" do
59
+ routes = ['a', 'b', 'c']
60
+ Druid::PageFactory.routes = {:default => routes}
61
+ expect(Druid::PageFactory.page_object_routes[:default]).to eql routes
62
+ end
63
+
64
+ it "should navigate to a page calling the default methods" do
65
+ pages = [[FactoryTestDruid, :a_method], [AnotherPage,:b_method]]
66
+ Druid::PageFactory.routes = {:default => pages}
67
+ fake_page = double('a_page')
68
+ expect(FactoryTestDruid).to receive(:new).with(driver,false).and_return(fake_page)
69
+ expect(fake_page).to receive(:a_method)
70
+ expect(world.navigate_to(AnotherPage).class).to eql AnotherPage
71
+ end
72
+
73
+ it "should fail when it does not find a proper route" do
74
+ Druid::PageFactory.routes = {:default => ['a'], :another => ['b']}
75
+ expect{world.navigate_to(AnotherPage, :using => :no_route)}.to raise_error 'PageFactory route :no_route not found'
76
+ end
77
+
78
+ it "should fail when no default method specified" do
79
+ Druid::PageFactory.routes = {:default => [[FactoryTestDruid, :a_method], [AnotherPage, :b_method]]}
80
+ fake_page = double('a_page')
81
+ expect(FactoryTestDruid).to receive(:new).and_return(fake_page)
82
+ expect(fake_page).to receive(:respond_to?).with(:a_method).and_return(false)
83
+ expect{world.navigate_to(AnotherPage)}.to raise_error
84
+ end
85
+
86
+ it "should know how to continue routing from a location" do
87
+ Druid::PageFactory.routes = {
88
+ :default => [[FactoryTestDruid, :a_method], [AnotherPage, :b_method], [YetAnotherPage, :c_method]]
89
+ }
90
+ fake_page = double('a_page')
91
+ expect(AnotherPage).to receive(:new).with(driver,false).and_return(fake_page)
92
+ expect(fake_page).to receive(:respond_to?).with(:b_method).and_return(true)
93
+ expect(fake_page).to receive(:b_method)
94
+ expect(fake_page).to receive(:class).and_return(FactoryTestDruid)
95
+ world.instance_variable_set :@current_page, fake_page
96
+ expect(world.continue_navigation_to(YetAnotherPage).class).to eql YetAnotherPage
97
+ end
98
+ end
metadata CHANGED
@@ -1,22 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: druid-ts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Sheng
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-07 00:00:00.000000000 Z
11
+ date: 2016-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: watir-webdriver
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: '0.9'
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
19
  version: 0.9.1
@@ -24,9 +21,6 @@ dependencies:
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - '='
28
- - !ruby/object:Gem::Version
29
- version: '0.9'
30
24
  - - ">="
31
25
  - !ruby/object:Gem::Version
32
26
  version: 0.9.1
@@ -95,6 +89,7 @@ files:
95
89
  - features/html/modal.html
96
90
  - features/html/modal_1.html
97
91
  - features/html/modal_2.html
92
+ - features/html/multi_elements.html
98
93
  - features/html/nested_elements.html
99
94
  - features/html/nested_frame_1.html
100
95
  - features/html/nested_frame_2.html
@@ -106,6 +101,7 @@ files:
106
101
  - features/link.feature
107
102
  - features/list_item.feature
108
103
  - features/modal_dialog.feature
104
+ - features/multi_elements.feature
109
105
  - features/nested_elements.feature
110
106
  - features/ordered_list.feature
111
107
  - features/page_level_actions.feature
@@ -127,6 +123,7 @@ files:
127
123
  - features/step_definations/link_steps.rb
128
124
  - features/step_definations/list_item_steps.rb
129
125
  - features/step_definations/modal_dialog_steps.rb
126
+ - features/step_definations/multi_elements_steps.rb
130
127
  - features/step_definations/nested_elements_steps.rb
131
128
  - features/step_definations/ordered_list_steps.rb
132
129
  - features/step_definations/page_level_actions_steps.rb
@@ -182,6 +179,7 @@ files:
182
179
  - lib/druid/nested_elements.rb
183
180
  - lib/druid/page_factory.rb
184
181
  - lib/druid/page_populator.rb
182
+ - lib/druid/version.rb
185
183
  - spec/druid/accessors_spec.rb
186
184
  - spec/druid/druid_spec.rb
187
185
  - spec/druid/element_locators_spec.rb
@@ -210,6 +208,7 @@ files:
210
208
  - spec/druid/elements/text_field_spec.rb
211
209
  - spec/druid/elements/unordered_list_spec.rb
212
210
  - spec/druid/nested_element_spec.rb
211
+ - spec/druid/page_factory_spec.rb
213
212
  - spec/druid/page_populator_spec.rb
214
213
  - spec/spec_helper.rb
215
214
  homepage: http://github.com/timsheng/druid
@@ -257,6 +256,7 @@ test_files:
257
256
  - features/html/modal.html
258
257
  - features/html/modal_1.html
259
258
  - features/html/modal_2.html
259
+ - features/html/multi_elements.html
260
260
  - features/html/nested_elements.html
261
261
  - features/html/nested_frame_1.html
262
262
  - features/html/nested_frame_2.html
@@ -268,6 +268,7 @@ test_files:
268
268
  - features/link.feature
269
269
  - features/list_item.feature
270
270
  - features/modal_dialog.feature
271
+ - features/multi_elements.feature
271
272
  - features/nested_elements.feature
272
273
  - features/ordered_list.feature
273
274
  - features/page_level_actions.feature
@@ -289,6 +290,7 @@ test_files:
289
290
  - features/step_definations/link_steps.rb
290
291
  - features/step_definations/list_item_steps.rb
291
292
  - features/step_definations/modal_dialog_steps.rb
293
+ - features/step_definations/multi_elements_steps.rb
292
294
  - features/step_definations/nested_elements_steps.rb
293
295
  - features/step_definations/ordered_list_steps.rb
294
296
  - features/step_definations/page_level_actions_steps.rb
@@ -340,5 +342,6 @@ test_files:
340
342
  - spec/druid/elements/text_field_spec.rb
341
343
  - spec/druid/elements/unordered_list_spec.rb
342
344
  - spec/druid/nested_element_spec.rb
345
+ - spec/druid/page_factory_spec.rb
343
346
  - spec/druid/page_populator_spec.rb
344
347
  - spec/spec_helper.rb