mohawk 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c7ab94d6b93e2f14327fa9747ea153e5216b1853
4
+ data.tar.gz: dc8fc1469e763cd93b400518145f1142b5c06443
5
+ SHA512:
6
+ metadata.gz: 43ec9b93a18ef6a7dc047eae81dfb1b90b3cd44a67887dd8972060d9744a373e902914c12fa5995975ba43b2ddb7494fadecf117cfaf79e870b48a1602e040fb
7
+ data.tar.gz: d3ce5ebdcfc9841dacb8dd6e3d28021f31f9428994ceec8a7955ecb3e355ca4412e66f01b4c1ac3e26396d849afa1373025c2ecdb1faa13a6f5e32a823b69bb2
@@ -1,6 +1,5 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../', 'lib'))
2
2
 
3
- require 'rspec-expectations'
4
3
  require 'childprocess'
5
4
  require 'mohawk'
6
5
 
@@ -5,7 +5,7 @@ class DataEntryForm
5
5
  table(:people, :id => "personListView")
6
6
  button(:add_more, :value => 'Add Many')
7
7
 
8
- def wait_until_present
8
+ def wait_until_present(context=nil)
9
9
  super
10
10
  wait_for_control :id => "personListView"
11
11
  end
@@ -17,7 +17,7 @@ module Mohawk
17
17
  end
18
18
 
19
19
  def required_controls(*controls)
20
- define_method(:wait_until_present) do
20
+ define_method(:wait_until_present) do |context=nil|
21
21
  controls.each do |control|
22
22
  super()
23
23
  begin
@@ -51,8 +51,8 @@ module Mohawk
51
51
  locate_element != nil
52
52
  end
53
53
 
54
- def wait_until_present
55
- wait_until { element }
54
+ def wait_until_present(context=nil)
55
+ wait_until(Mohawk.timeout, context) { element }
56
56
  end
57
57
 
58
58
  private
@@ -66,4 +66,4 @@ module Mohawk
66
66
  end
67
67
  end
68
68
  end
69
- end
69
+ end
@@ -6,6 +6,8 @@ module Mohawk
6
6
  class UiaAdapter
7
7
  include UIA
8
8
 
9
+ attr_reader :locator
10
+
9
11
  def initialize(locator, container=nil)
10
12
  @children_only = locator.delete :children_only
11
13
  @locator = locator
@@ -74,4 +76,4 @@ module Mohawk
74
76
  end
75
77
  end
76
78
  end
77
- end
79
+ end
@@ -6,7 +6,7 @@ module Mohawk
6
6
 
7
7
  def on(cls, extra={}, &block)
8
8
  screen = cls.new extra
9
- screen.wait_until_present
9
+ screen.wait_until_present "Unable to locate #{cls} using #{screen.adapter.locator}"
10
10
  block.call screen if block
11
11
  screen
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module Mohawk
2
- VERSION = "0.4.2"
2
+ VERSION = '0.4.3'
3
3
  end
data/lib/mohawk/waiter.rb CHANGED
@@ -5,14 +5,14 @@ module Mohawk
5
5
  class WaitTimeout < StandardError;
6
6
  end
7
7
 
8
- def wait_until(timeout=Mohawk.timeout, &block)
8
+ def wait_until(timeout=Mohawk.timeout, context=nil, &block)
9
9
  start = Time.now
10
10
  until (result = block.call) || (Time.now - start > timeout)
11
11
  sleep 0.25
12
12
  end
13
13
 
14
- raise WaitTimeout unless result
14
+ raise WaitTimeout, context unless result
15
15
  result
16
16
  end
17
17
  end
18
- end
18
+ end
data/lib/mohawk.rb CHANGED
@@ -91,8 +91,8 @@ module Mohawk
91
91
  #
92
92
  # Waits until the window is present
93
93
  #
94
- def wait_until_present
95
- adapter.window.wait_until_present
94
+ def wait_until_present(context=nil)
95
+ adapter.window.wait_until_present context
96
96
  end
97
97
 
98
98
  #
data/mohawk.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |gem|
24
24
  gem.add_dependency 'childprocess', '~> 0.5'
25
25
 
26
26
  gem.add_development_dependency 'cucumber'
27
- gem.add_development_dependency 'rspec', '2.14.1'
27
+ gem.add_development_dependency 'rspec', '3.5.0'
28
28
  gem.add_development_dependency 'rspec-given'
29
29
  gem.add_development_dependency 'rake'
30
30
  gem.add_development_dependency 'childprocess'
@@ -32,5 +32,5 @@ Gem::Specification.new do |gem|
32
32
  gem.add_development_dependency 'guard'
33
33
  gem.add_development_dependency 'guard-rspec'
34
34
  gem.add_development_dependency 'terminal-notifier-guard'
35
- gem.add_development_dependency 'json', '~> 1.7.7'
35
+ gem.add_development_dependency 'json', '~> 2.1.0'
36
36
  end
@@ -29,7 +29,7 @@ describe Mohawk::Adapters::UiaAdapter::Control do
29
29
  end
30
30
 
31
31
  context '#patterns' do
32
- Given { parent.stub(:find) {|l| @locator = l } }
32
+ Given { allow(parent).to receive(:find) {|l| @locator = l } }
33
33
  Given(:no_filter) { new_control(id: 'hi') }
34
34
  Given(:some_filter) { HasPattern.new adapter, id: 'hi' }
35
35
  Given(:overridden) { HasPattern.new adapter, id: 'hi', pattern: :overridden }
@@ -8,8 +8,8 @@ describe Mohawk::Adapters::UIA::TableRow do
8
8
  subject { Mohawk::Adapters::UIA::TableRow.new table, 123 }
9
9
 
10
10
  def set_expected_cells(h)
11
- element.stub(:items).and_return h.values.map {|v| UiaTableCell.new v }
12
- table.stub(:headers).and_return h.keys.map(&:to_s)
11
+ allow(element).to receive(:items).and_return h.values.map {|v| UiaTableCell.new v }
12
+ allow(table).to receive(:headers).and_return h.keys.map(&:to_s)
13
13
  end
14
14
 
15
15
  context '#all_match?' do
@@ -1,5 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
+ def non_existent_locator
4
+ {:title => /I don't exist/}
5
+ end
6
+
7
+ class NonExistentScreen
8
+ include Mohawk
9
+ window non_existent_locator
10
+ end
11
+
3
12
  describe Mohawk::Navigation do
4
13
  context '#on with extra info' do
5
14
  When { start_app }
@@ -22,4 +31,12 @@ describe Mohawk::Navigation do
22
31
  When(:data_entry_form) { navigate_to(DataEntryForm) }
23
32
  Then { expect(data_entry_form).to be_present }
24
33
  end
25
- end
34
+
35
+ context 'name the screen that could not be found' do
36
+ When { Mohawk.timeout = 1 }
37
+ Then do
38
+ screen_class = NonExistentScreen
39
+ expect { on(screen_class) }.to raise_error Mohawk::Waiter::WaitTimeout, "Unable to locate #{screen_class} using #{non_existent_locator}"
40
+ end
41
+ end
42
+ end
@@ -30,10 +30,22 @@ describe Mohawk::Waiter do
30
30
 
31
31
  context 'waits in between' do
32
32
  When do
33
- @fake_responses = [false, true]
33
+ @fake_responses = [false, true]
34
34
  fake_time 0, 1
35
35
  end
36
36
 
37
37
  Then { expect { waiter.wait_until { do_it } }.not_to raise_error }
38
38
  end
39
- end
39
+
40
+ context 'accepts context parameter' do
41
+ Then { expect { waiter.wait_until(1, 'This is the context') { true } }.not_to raise_error }
42
+ end
43
+
44
+ context 'outputs context on error' do
45
+ Then do
46
+ context_string = 'This is the context'
47
+ expect { waiter.wait_until(1, context_string) { false } }.to raise_error Mohawk::Waiter::WaitTimeout, context_string
48
+ end
49
+ end
50
+
51
+ end
@@ -46,12 +46,12 @@ describe Mohawk do
46
46
  let(:process) { double 'child process', pid: 123 }
47
47
 
48
48
  before(:each) do
49
- Uia.stub(:find_element).and_return double
50
- process.stub(:start).and_return(process)
51
- [:exited?, :stop].each &process.method(:stub)
52
- ChildProcess.stub(:build).with('./the/app/path.exe').and_return(process)
49
+ allow(Uia).to receive(:find_element).and_return double
50
+ allow(process).to receive(:start).and_return(process)
51
+ [:exited?, :stop].each { |x| allow(process).to receive(x) }
52
+ allow(ChildProcess).to receive(:build).with('./the/app/path.exe').and_return(process)
53
53
 
54
- window.stub(:present?).and_return(true)
54
+ allow(window).to receive(:present?).and_return(true)
55
55
 
56
56
  Mohawk.app_path = './the/app/path.exe'
57
57
  end
@@ -131,7 +131,10 @@ describe Mohawk do
131
131
  context Mohawk::Adapters do
132
132
  Given(:screen) { TestScreen.new }
133
133
  Given(:window) { double('window').as_null_object }
134
- Given { screen.adapter.stub(:window).and_return window }
134
+ Given do
135
+ allow(screen.adapter).to receive(:window).and_return window
136
+ allow(window).to receive(:present?)
137
+ end
135
138
 
136
139
  context 'window' do
137
140
  context '#exist?' do
@@ -7,7 +7,7 @@ include Mohawk::Navigation
7
7
 
8
8
  describe Mohawk::Navigation do
9
9
  before(:each) do
10
- NavigationTestScreen.stub(:new).and_return(screen)
10
+ allow(NavigationTestScreen).to receive(:new).and_return(screen)
11
11
  end
12
12
 
13
13
  Given(:screen) { double('Mohawk Screen').as_null_object }
metadata CHANGED
@@ -1,240 +1,211 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mohawk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
5
- prerelease:
4
+ version: 0.4.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Levi Wilson
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-10-29 00:00:00.000000000 Z
11
+ date: 2017-12-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: uia
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0.5'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0.5'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: require_all
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: page_navigation
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0.7'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0.7'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: childprocess
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0.5'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0.5'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: cucumber
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rspec
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - '='
100
88
  - !ruby/object:Gem::Version
101
- version: 2.14.1
89
+ version: 3.5.0
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - '='
108
95
  - !ruby/object:Gem::Version
109
- version: 2.14.1
96
+ version: 3.5.0
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rspec-given
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - ">="
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: rake
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - ">="
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - ">="
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: childprocess
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - ">="
148
130
  - !ruby/object:Gem::Version
149
131
  version: '0'
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - ">="
156
137
  - !ruby/object:Gem::Version
157
138
  version: '0'
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: rb-fsevent
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
- - - ~>
143
+ - - "~>"
164
144
  - !ruby/object:Gem::Version
165
145
  version: 0.9.1
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
- - - ~>
150
+ - - "~>"
172
151
  - !ruby/object:Gem::Version
173
152
  version: 0.9.1
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: guard
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
- - - ! '>='
157
+ - - ">="
180
158
  - !ruby/object:Gem::Version
181
159
  version: '0'
182
160
  type: :development
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
- - - ! '>='
164
+ - - ">="
188
165
  - !ruby/object:Gem::Version
189
166
  version: '0'
190
167
  - !ruby/object:Gem::Dependency
191
168
  name: guard-rspec
192
169
  requirement: !ruby/object:Gem::Requirement
193
- none: false
194
170
  requirements:
195
- - - ! '>='
171
+ - - ">="
196
172
  - !ruby/object:Gem::Version
197
173
  version: '0'
198
174
  type: :development
199
175
  prerelease: false
200
176
  version_requirements: !ruby/object:Gem::Requirement
201
- none: false
202
177
  requirements:
203
- - - ! '>='
178
+ - - ">="
204
179
  - !ruby/object:Gem::Version
205
180
  version: '0'
206
181
  - !ruby/object:Gem::Dependency
207
182
  name: terminal-notifier-guard
208
183
  requirement: !ruby/object:Gem::Requirement
209
- none: false
210
184
  requirements:
211
- - - ! '>='
185
+ - - ">="
212
186
  - !ruby/object:Gem::Version
213
187
  version: '0'
214
188
  type: :development
215
189
  prerelease: false
216
190
  version_requirements: !ruby/object:Gem::Requirement
217
- none: false
218
191
  requirements:
219
- - - ! '>='
192
+ - - ">="
220
193
  - !ruby/object:Gem::Version
221
194
  version: '0'
222
195
  - !ruby/object:Gem::Dependency
223
196
  name: json
224
197
  requirement: !ruby/object:Gem::Requirement
225
- none: false
226
198
  requirements:
227
- - - ~>
199
+ - - "~>"
228
200
  - !ruby/object:Gem::Version
229
- version: 1.7.7
201
+ version: 2.1.0
230
202
  type: :development
231
203
  prerelease: false
232
204
  version_requirements: !ruby/object:Gem::Requirement
233
- none: false
234
205
  requirements:
235
- - - ~>
206
+ - - "~>"
236
207
  - !ruby/object:Gem::Version
237
- version: 1.7.7
208
+ version: 2.1.0
238
209
  description: Mohawk is a page-object style driver that makes it easy to automate windows
239
210
  applications. It allows you to create a very flexible, clean and natural DSL around
240
211
  whatever windows application that you are trying to automate using the RAutomation
@@ -245,9 +216,9 @@ executables: []
245
216
  extensions: []
246
217
  extra_rdoc_files: []
247
218
  files:
248
- - .gitignore
249
- - .gitmodules
250
- - .travis.yml
219
+ - ".gitignore"
220
+ - ".gitmodules"
221
+ - ".travis.yml"
251
222
  - Changelog
252
223
  - Gemfile
253
224
  - Guardfile
@@ -342,33 +313,26 @@ files:
342
313
  homepage: http://github.com/leviwilson/mohawk
343
314
  licenses:
344
315
  - MIT
316
+ metadata: {}
345
317
  post_install_message:
346
318
  rdoc_options: []
347
319
  require_paths:
348
320
  - lib
349
321
  required_ruby_version: !ruby/object:Gem::Requirement
350
- none: false
351
322
  requirements:
352
- - - ! '>='
323
+ - - ">="
353
324
  - !ruby/object:Gem::Version
354
325
  version: '0'
355
- segments:
356
- - 0
357
- hash: 652197775
358
326
  required_rubygems_version: !ruby/object:Gem::Requirement
359
- none: false
360
327
  requirements:
361
- - - ! '>='
328
+ - - ">="
362
329
  - !ruby/object:Gem::Version
363
330
  version: '0'
364
- segments:
365
- - 0
366
- hash: 652197775
367
331
  requirements: []
368
332
  rubyforge_project:
369
- rubygems_version: 1.8.28
333
+ rubygems_version: 2.5.2
370
334
  signing_key:
371
- specification_version: 3
335
+ specification_version: 4
372
336
  summary: Provides a page-object style driver for automating Windows applications
373
337
  test_files:
374
338
  - features/step_definitions/table_steps.rb