rutl 0.6.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.bundle/config +2 -0
  3. data/.gitignore +1 -1
  4. data/.rubocop.yml +1 -1
  5. data/.rubocop_todo.yml +37 -10
  6. data/.travis.yml +1 -0
  7. data/README.md +75 -38
  8. data/appveyor.yml +48 -0
  9. data/bin/ie.reg +0 -0
  10. data/bin/window_data.rb +27 -0
  11. data/lib/rspec/default_method_object_to_app.rb +28 -0
  12. data/lib/rspec/rutl_matchers.rb +7 -5
  13. data/lib/rutl.rb +26 -6
  14. data/lib/rutl/appium/appium_extension.rb +27 -0
  15. data/lib/rutl/appium/appium_server.rb +36 -0
  16. data/lib/rutl/appium/windows_test_app_wrapper.rb +40 -0
  17. data/lib/rutl/application.rb +70 -0
  18. data/lib/rutl/camera.rb +20 -4
  19. data/lib/rutl/element/click_to_change_state_mixin.rb +1 -1
  20. data/lib/rutl/element/element.rb +9 -10
  21. data/lib/rutl/element/element_context.rb +5 -4
  22. data/lib/rutl/element/string_reader_writer_mixin.rb +11 -7
  23. data/lib/rutl/interface/base.rb +30 -28
  24. data/lib/rutl/interface/browser/browser.rb +22 -0
  25. data/lib/rutl/interface/{chrome.rb → browser/chrome.rb} +3 -10
  26. data/lib/rutl/interface/{firefox.rb → browser/firefox.rb} +3 -10
  27. data/lib/rutl/interface/browser/internet_explorer.rb +23 -0
  28. data/lib/rutl/interface/browser/null.rb +36 -0
  29. data/lib/rutl/interface/windows/hello.rb +36 -0
  30. data/lib/rutl/interface/windows/notepad.rb +26 -0
  31. data/lib/rutl/interface/windows/windows_app.rb +35 -0
  32. data/lib/rutl/null_driver/null_driver.rb +4 -4
  33. data/lib/rutl/null_driver/null_element.rb +4 -4
  34. data/lib/rutl/version.rb +1 -1
  35. data/lib/rutl/{page.rb → view.rb} +37 -28
  36. data/lib/utilities/check_view.rb +12 -0
  37. data/lib/utilities/string.rb +12 -0
  38. data/lib/utilities/waiter.rb +23 -0
  39. data/rutl.gemspec +13 -0
  40. metadata +94 -10
  41. data/lib/rspec/default_rspec_to_browser.rb +0 -22
  42. data/lib/rutl/browser.rb +0 -70
  43. data/lib/rutl/interface/null.rb +0 -35
  44. data/lib/utilities.rb +0 -41
@@ -0,0 +1,12 @@
1
+ #
2
+ # Extend string class to PascalCase* snake_cased_strings.
3
+ # Monkey patching that's only needed in this file so far.
4
+ # Move it to utilitiies? Other?
5
+ #
6
+ # * It's Pascal case, not camel case. It starts with a capital.
7
+ #
8
+ class String
9
+ def pascal_case
10
+ split('_').map(&:capitalize).join
11
+ end
12
+ end
@@ -0,0 +1,23 @@
1
+ #
2
+ # The waiter waits.
3
+ #
4
+ module Waiter
5
+ require 'timeout'
6
+
7
+ POLL_SLEEP_TIME = 0.01
8
+ DEFAULT_TIMEOUT = 5
9
+
10
+ # The lambda passed to await should return false if thing not found
11
+ # and something truthy if found
12
+ def await(lamb, timeout = DEFAULT_TIMEOUT, poll_sleep_time = POLL_SLEEP_TIME)
13
+ Timeout.timeout(timeout) do
14
+ loop do
15
+ result = lamb.call
16
+ return result if result
17
+ # rubocop:disable Style/SleepCop
18
+ sleep poll_sleep_time
19
+ # rubocop:enable Style/SleepCop
20
+ end
21
+ end
22
+ end
23
+ end
data/rutl.gemspec CHANGED
@@ -38,6 +38,19 @@ Gem::Specification.new do |spec|
38
38
  # Works locally and with Travis.
39
39
  spec.add_dependency 'webdrivers', '~> 3.0'
40
40
 
41
+ # everything but browsers
42
+ spec.add_dependency 'appium_lib', '~> 9.14'
43
+ # need eventmachine for Appium
44
+ spec.add_dependency 'eventmachine', '~> 1.2'
45
+ # using this to talk HTTP to the Appium server
46
+ spec.add_dependency 'faraday', '~> 0.15'
47
+ if ENV['OS'] == 'Windows_NT'
48
+ # to get native window handles on Windows
49
+ spec.add_dependency 'win32-window', '~> 0.2.0.pre'
50
+ # my test app uses this
51
+ spec.add_dependency 'tk', '~> 0.2'
52
+ end
53
+
41
54
  # Dependencies for development only.
42
55
  spec.add_development_dependency 'bundler', '~> 1.15'
43
56
  spec.add_development_dependency 'gem-release', '~> 1.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rutl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drew Cooper
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-08 00:00:00.000000000 Z
11
+ date: 2018-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -38,6 +38,76 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: appium_lib
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '9.14'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '9.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: eventmachine
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.15'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.15'
83
+ - !ruby/object:Gem::Dependency
84
+ name: win32-window
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.2.0.pre
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.2.0.pre
97
+ - !ruby/object:Gem::Dependency
98
+ name: tk
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.2'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.2'
41
111
  - !ruby/object:Gem::Dependency
42
112
  name: bundler
43
113
  requirement: !ruby/object:Gem::Requirement
@@ -171,6 +241,7 @@ executables: []
171
241
  extensions: []
172
242
  extra_rdoc_files: []
173
243
  files:
244
+ - ".bundle/config"
174
245
  - ".circleci/config.yml"
175
246
  - ".coveralls.yml"
176
247
  - ".gitignore"
@@ -182,12 +253,18 @@ files:
182
253
  - LICENSE.txt
183
254
  - README.md
184
255
  - Rakefile
256
+ - appveyor.yml
185
257
  - bin/console
258
+ - bin/ie.reg
186
259
  - bin/setup
187
- - lib/rspec/default_rspec_to_browser.rb
260
+ - bin/window_data.rb
261
+ - lib/rspec/default_method_object_to_app.rb
188
262
  - lib/rspec/rutl_matchers.rb
189
263
  - lib/rutl.rb
190
- - lib/rutl/browser.rb
264
+ - lib/rutl/appium/appium_extension.rb
265
+ - lib/rutl/appium/appium_server.rb
266
+ - lib/rutl/appium/windows_test_app_wrapper.rb
267
+ - lib/rutl/application.rb
191
268
  - lib/rutl/camera.rb
192
269
  - lib/rutl/element.rb
193
270
  - lib/rutl/element/button.rb
@@ -199,14 +276,21 @@ files:
199
276
  - lib/rutl/element/string_reader_writer_mixin.rb
200
277
  - lib/rutl/element/text.rb
201
278
  - lib/rutl/interface/base.rb
202
- - lib/rutl/interface/chrome.rb
203
- - lib/rutl/interface/firefox.rb
204
- - lib/rutl/interface/null.rb
279
+ - lib/rutl/interface/browser/browser.rb
280
+ - lib/rutl/interface/browser/chrome.rb
281
+ - lib/rutl/interface/browser/firefox.rb
282
+ - lib/rutl/interface/browser/internet_explorer.rb
283
+ - lib/rutl/interface/browser/null.rb
284
+ - lib/rutl/interface/windows/hello.rb
285
+ - lib/rutl/interface/windows/notepad.rb
286
+ - lib/rutl/interface/windows/windows_app.rb
205
287
  - lib/rutl/null_driver/null_driver.rb
206
288
  - lib/rutl/null_driver/null_element.rb
207
- - lib/rutl/page.rb
208
289
  - lib/rutl/version.rb
209
- - lib/utilities.rb
290
+ - lib/rutl/view.rb
291
+ - lib/utilities/check_view.rb
292
+ - lib/utilities/string.rb
293
+ - lib/utilities/waiter.rb
210
294
  - rutl.gemspec
211
295
  homepage: https://github.com/drewcoo/rutl
212
296
  licenses:
@@ -229,7 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
313
  version: '0'
230
314
  requirements: []
231
315
  rubyforge_project:
232
- rubygems_version: 2.7.6
316
+ rubygems_version: 2.7.7
233
317
  signing_key:
234
318
  specification_version: 4
235
319
  summary: Ruby Ui Test Library
@@ -1,22 +0,0 @@
1
- #
2
- # Currently not in use.
3
- # Should go in its own file, too.
4
- #
5
- module DefaultRspecToBrowser
6
- # rubocop:disable Style/MethodMissingSuper
7
- def method_missing(method, *args, &block)
8
- if args.empty?
9
- browser.send(method)
10
- else
11
- browser.send(method, *args, &block)
12
- end
13
- rescue ArgumentError
14
- browser.send(method)
15
- end
16
- # rubocop:enable Style/MethodMissingSuper
17
-
18
- def respond_to_missing?(method, _include_private = false)
19
- return false if method =~ /browser/
20
- browser.respond_to?(method)
21
- end
22
- end
data/lib/rutl/browser.rb DELETED
@@ -1,70 +0,0 @@
1
- require 'utilities'
2
- require 'rutl/page'
3
-
4
- module RUTL
5
- #
6
- # Currently called Browser, this top-level class controls a browser and
7
- # a fake browser. It will soon call into apps, at which point I need to
8
- # rethink this naming convention.
9
- #
10
- class Browser
11
- include Utilities
12
-
13
- attr_reader :interface
14
-
15
- def initialize(type:, rutl_pages: RUTL::PAGES || ENV['RUTL_PAGES'])
16
- if rutl_pages.nil? || rutl_pages.empty?
17
- raise "Set RUTL::PAGES or ENV['RUTL_PAGES'] or pass dir as rutl_pages:"
18
- end
19
- # This is kind of evil. Figure out how to ditch the $ variable.
20
- $browser = self
21
- @interface = nil # TODO: Why this line? Do I need to do this?
22
- @interface = load_interface(type)
23
- @interface.pages = load_pages(dir: rutl_pages)
24
- end
25
-
26
- def method_missing(method, *args, &block)
27
- if args.empty?
28
- @interface.send(method)
29
- else
30
- @interface.send(method, *args, &block)
31
- end
32
- end
33
-
34
- def respond_to_missing?(*args)
35
- @interface.respond_to?(*args)
36
- end
37
-
38
- private
39
-
40
- def load_interface(type)
41
- require "rutl/interface/#{type}"
42
- klass = "RUTL::Interface::#{type.to_s.capitalize}"
43
- Object.const_get(klass).new
44
- end
45
-
46
- def load_pages(*)
47
- pages = []
48
- require_pages.each do |klass|
49
- # Don't have @interface set yet.
50
- # That would have been the param to new, :interface.
51
- pages << Object.const_get(klass).new(@interface)
52
- end
53
- pages
54
- end
55
-
56
- # Ugly. Requires files for page objects.
57
- # Returns array of class names to load.
58
- def require_pages(dir: 'spec/pages')
59
- names = []
60
- Dir["#{dir}/*"].each do |file|
61
- require "rutl/../../#{file}"
62
- File.open(file).each do |line|
63
- bingo = line.match(/class (.*) < RUTL::Page/)
64
- names << bingo[1] if bingo && bingo[1]
65
- end
66
- end
67
- names
68
- end
69
- end
70
- end
@@ -1,35 +0,0 @@
1
- require 'rutl/interface/base'
2
-
3
- module RUTL
4
- module Interface
5
- #
6
- # Interface-level code for fake browser.
7
- #
8
- class Null < Base
9
- def initialize
10
- context = RUTL::Element::ElementContext.new(destinations: nil,
11
- interface: self,
12
- selectors: [])
13
- @driver = NullDriver.new(context)
14
- super
15
- end
16
-
17
- # The null driver needs to talk to the null interface.
18
- # Other driver/interface relations are not like this.
19
- attr_writer :current_page
20
-
21
- def current_page
22
- # Default to @pages.first if not set?
23
- # A browser can always check its current URL but the null driver can't.
24
- @current_page ||= @pages.first
25
- end
26
-
27
- def wait_for_transition(destinations)
28
- # TODO: Setting @current page didn't do it beacause that set
29
- # context.interface.current_page and we wanted this in the browser.
30
- @current_page = destinations.first.new(self)
31
- $browser.current_page = @current_page
32
- end
33
- end
34
- end
35
- end
data/lib/utilities.rb DELETED
@@ -1,41 +0,0 @@
1
- #
2
- # A catch-all bag for stuff I don't have elsewhere yet.
3
- #
4
- module Utilities
5
- require 'timeout'
6
-
7
- POLL_SLEEP_TIME = 0.01
8
- DEFAULT_TIMEOUT = 5
9
-
10
- # The lambda passed to await should return false if thing not found
11
- # and something truthy if found
12
- def await(lamb, timeout = DEFAULT_TIMEOUT, poll_sleep_time = POLL_SLEEP_TIME)
13
- Timeout.timeout(timeout) do
14
- loop do
15
- result = lamb.call
16
- return result if result
17
- # rubocop:disable Style/SleepCop
18
- sleep poll_sleep_time
19
- # rubocop:enable Style/SleepCop
20
- end
21
- end
22
- end
23
-
24
- def class_info(object)
25
- result = "CLASS: #{object.class}"
26
- result += "\nmethods: #{(object.methods - Class.methods).sort}\n"
27
- result
28
- end
29
-
30
- # Just call "caller" with no args for stack trace.
31
- def location
32
- caller(1..1).first
33
- end
34
-
35
- def page?(checkme)
36
- checkme.ancestors.include?(RUTL::Page)
37
- rescue NoMethodError
38
- # This isn't a even a class. It's no page!
39
- false
40
- end
41
- end