moto 0.7.7 → 0.8.0
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.
- checksums.yaml +4 -4
- data/lib/cli.rb +0 -3
- data/lib/empty_listener.rb +16 -16
- data/lib/exceptions/moto.rb +6 -6
- data/lib/exceptions/test_forced_failure.rb +6 -6
- data/lib/exceptions/test_forced_passed.rb +6 -6
- data/lib/exceptions/test_skipped.rb +6 -6
- data/lib/runner/test_generator.rb +3 -61
- data/lib/runner/test_runner.rb +0 -2
- data/lib/runner/thread_context.rb +0 -7
- data/lib/test/base.rb +0 -19
- data/lib/test_logging.rb +0 -4
- data/lib/version.rb +1 -1
- metadata +2 -6
- data/lib/clients/base.rb +0 -30
- data/lib/clients/clients_manager.rb +0 -51
- data/lib/clients/website.rb +0 -103
- data/lib/page.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b6682d6947aa0e2a4ab20dad51e6ce82dbbf5e4
|
4
|
+
data.tar.gz: e53c36116cfd2c832066f7054038ac58a34c3007
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d680940903bd84cf2491a4bbaa4ec796b2c1970d352402fa0b2bf219cd7937392c0471da609edc15bba245882552a2f942f40700ae26ac850767cf7e0264c5b
|
7
|
+
data.tar.gz: f122b9d617435150968650287dfc71d7ee64d8518134ebd0e4b7baf75f3a3e29370accd3bb2f3bba139e005c40e09368bf86122cb873a8a17673cd49202d55e8
|
data/lib/cli.rb
CHANGED
@@ -12,16 +12,13 @@ module Moto
|
|
12
12
|
DIR = File.dirname(File.dirname(__FILE__))
|
13
13
|
end
|
14
14
|
|
15
|
-
require_relative './empty_listener'
|
16
15
|
require_relative './test_logging'
|
17
16
|
require_relative './runner_logging'
|
18
17
|
require_relative './runner/test_runner'
|
19
18
|
require_relative './runner/thread_context'
|
20
19
|
require_relative './runner/test_generator'
|
21
20
|
require_relative './test/base'
|
22
|
-
require_relative './page'
|
23
21
|
require_relative './version'
|
24
|
-
require_relative './clients/base'
|
25
22
|
require_relative './reporting/listeners/base'
|
26
23
|
require_relative './reporting/listeners/console'
|
27
24
|
require_relative './reporting/listeners/console_dots'
|
data/lib/empty_listener.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
module Moto
|
2
|
-
module EmptyListener
|
3
|
-
|
4
|
-
def start_run
|
5
|
-
end
|
6
|
-
|
7
|
-
def end_run
|
8
|
-
end
|
9
|
-
|
10
|
-
def start_test(test)
|
11
|
-
end
|
12
|
-
|
13
|
-
def end_test(test)
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
1
|
+
module Moto
|
2
|
+
module EmptyListener
|
3
|
+
|
4
|
+
def start_run
|
5
|
+
end
|
6
|
+
|
7
|
+
def end_run
|
8
|
+
end
|
9
|
+
|
10
|
+
def start_test(test)
|
11
|
+
end
|
12
|
+
|
13
|
+
def end_test(test)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
17
|
end
|
data/lib/exceptions/moto.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
module Moto
|
2
|
-
module Exceptions
|
3
|
-
class MotoException < RuntimeError
|
4
|
-
|
5
|
-
end
|
6
|
-
end
|
1
|
+
module Moto
|
2
|
+
module Exceptions
|
3
|
+
class MotoException < RuntimeError
|
4
|
+
|
5
|
+
end
|
6
|
+
end
|
7
7
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
module Moto
|
2
|
-
module Exceptions
|
3
|
-
class TestForcedFailure < MotoException
|
4
|
-
|
5
|
-
end
|
6
|
-
end
|
1
|
+
module Moto
|
2
|
+
module Exceptions
|
3
|
+
class TestForcedFailure < MotoException
|
4
|
+
|
5
|
+
end
|
6
|
+
end
|
7
7
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
module Moto
|
2
|
-
module Exceptions
|
3
|
-
class TestForcedPassed < MotoException
|
4
|
-
|
5
|
-
end
|
6
|
-
end
|
1
|
+
module Moto
|
2
|
+
module Exceptions
|
3
|
+
class TestForcedPassed < MotoException
|
4
|
+
|
5
|
+
end
|
6
|
+
end
|
7
7
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
module Moto
|
2
|
-
module Exceptions
|
3
|
-
class TestSkipped < MotoException
|
4
|
-
|
5
|
-
end
|
6
|
-
end
|
1
|
+
module Moto
|
2
|
+
module Exceptions
|
3
|
+
class TestSkipped < MotoException
|
4
|
+
|
5
|
+
end
|
6
|
+
end
|
7
7
|
end
|
@@ -62,23 +62,10 @@ module Moto
|
|
62
62
|
end
|
63
63
|
private :variantize
|
64
64
|
|
65
|
-
#
|
65
|
+
# Generates test instances
|
66
|
+
# @return [Moto::Test::Base]
|
66
67
|
def generate(test_path_absolute)
|
67
|
-
method_body = File.read(test_path_absolute) + "\n"
|
68
|
-
|
69
|
-
full_code = !!method_body.match(/^#\s*FULL_CODE\s+/)
|
70
|
-
|
71
|
-
if full_code
|
72
|
-
generate_for_full_class_code(test_path_absolute)
|
73
|
-
else
|
74
|
-
generate_for_run_body(test_path_absolute, method_body)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
private :generate
|
78
68
|
|
79
|
-
# Generates test instances, based on fully defined class file
|
80
|
-
# @return [Moto::Test::Base]
|
81
|
-
def generate_for_full_class_code(test_path_absolute)
|
82
69
|
# Checking if it's possible to create test based on provided path. In case something is wrong with
|
83
70
|
# modules structure in class itself Moto::Test::Base will be instantized with raise injected into its run()
|
84
71
|
# so we can have proper reporting and summary even if the test doesn't execute.
|
@@ -98,52 +85,7 @@ module Moto
|
|
98
85
|
test_object.evaled = false
|
99
86
|
test_object
|
100
87
|
end
|
101
|
-
private :
|
102
|
-
|
103
|
-
def create_module_tree(root_module, next_modules)
|
104
|
-
return root_module if next_modules.empty?
|
105
|
-
next_module_name = next_modules.shift
|
106
|
-
if root_module.const_defined?(next_module_name.to_sym)
|
107
|
-
m = root_module.const_get(next_module_name.to_sym)
|
108
|
-
else
|
109
|
-
m = Module.new
|
110
|
-
root_module.const_set(next_module_name.to_sym, m)
|
111
|
-
end
|
112
|
-
create_module_tree(m, next_modules)
|
113
|
-
end
|
114
|
-
private :create_module_tree
|
115
|
-
|
116
|
-
# Generates test instances, based on a text file with ruby code that has to be injected into run() method
|
117
|
-
# @return [Moto::Test::Base]
|
118
|
-
def generate_for_run_body(test_path_absolute, method_body)
|
119
|
-
base = Moto::Test::Base
|
120
|
-
base_class_string = method_body.match(/^#\s*BASE_CLASS:\s(\S+)/)
|
121
|
-
unless base_class_string.nil?
|
122
|
-
base_class_string = base_class_string[1].strip
|
123
|
-
|
124
|
-
a = base_class_string.underscore.split('/')
|
125
|
-
base_test_path = a[1..-1].join('/')
|
126
|
-
|
127
|
-
require "#{MotoApp::DIR}/#{base_test_path}"
|
128
|
-
base = base_class_string.constantize
|
129
|
-
end
|
130
|
-
|
131
|
-
# MotoApp::Tests::Login::Short
|
132
|
-
consts = test_path_absolute.camelize.split('Tests::')[1].split('::')
|
133
|
-
consts.pop
|
134
|
-
class_name = consts.pop
|
135
|
-
|
136
|
-
m = create_module_tree(MotoApp::Tests, consts)
|
137
|
-
cls = Class.new(base)
|
138
|
-
m.const_set(class_name.to_sym, cls)
|
139
|
-
|
140
|
-
test_object = cls.new
|
141
|
-
test_object.instance_eval("def run\n #{method_body} \n end")
|
142
|
-
test_object.static_path = test_path_absolute
|
143
|
-
test_object.evaled = true
|
144
|
-
test_object
|
145
|
-
end
|
146
|
-
private :generate_for_run_body
|
88
|
+
private :generate
|
147
89
|
|
148
90
|
# Injects raise into test.run so it will report an error when executed
|
149
91
|
# @param [Moto::Test::Base] test An instance of test that is supposed to be modified
|
data/lib/runner/test_runner.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'erb'
|
2
2
|
require 'fileutils'
|
3
3
|
require_relative '../../lib/config'
|
4
|
-
require_relative '../../lib/clients/clients_manager'
|
5
4
|
|
6
5
|
module Moto
|
7
6
|
module Runner
|
@@ -31,7 +30,6 @@ module Moto
|
|
31
30
|
|
32
31
|
(1..max_attempts).each do |attempt|
|
33
32
|
|
34
|
-
Thread.current['clients_manager'].clients.each_value { |c| c.start_test(@test) }
|
35
33
|
@test.before
|
36
34
|
Thread.current['logger'].info("Start: #{@test.name} attempt #{attempt}/#{max_attempts}")
|
37
35
|
|
@@ -42,11 +40,9 @@ module Moto
|
|
42
40
|
rescue Exception => e
|
43
41
|
Thread.current['logger'].error("#{e.class.name}: #{e.message}")
|
44
42
|
Thread.current['logger'].error(e.backtrace.join("\n"))
|
45
|
-
Thread.current['clients_manager'].clients.each_value { |c| c.handle_test_exception(@test, e) }
|
46
43
|
end
|
47
44
|
|
48
45
|
@test.after
|
49
|
-
Thread.current['clients_manager'].clients.each_value { |c| c.end_test(@test) }
|
50
46
|
|
51
47
|
Thread.current['logger'].info("Result: #{@test.status.results.last.code}")
|
52
48
|
|
@@ -68,9 +64,6 @@ module Moto
|
|
68
64
|
|
69
65
|
# Reporting: end_test
|
70
66
|
@test_reporter.report_end_test(@test.status)
|
71
|
-
|
72
|
-
Thread.current['clients_manager'].clients.each_value { |c| c.end_run }
|
73
|
-
|
74
67
|
end
|
75
68
|
|
76
69
|
# @return [Hash] Hash with config for ThreadContext
|
data/lib/test/base.rb
CHANGED
@@ -52,17 +52,6 @@ module Moto
|
|
52
52
|
@log_path
|
53
53
|
end
|
54
54
|
|
55
|
-
#TODO Remove possibly?
|
56
|
-
# def dir
|
57
|
-
# return File.dirname(static_path) unless static_path.nil?
|
58
|
-
# File.dirname(self.path)
|
59
|
-
# end
|
60
|
-
#
|
61
|
-
# def filename
|
62
|
-
# return File.basename(static_path, '.*') unless static_path.nil?
|
63
|
-
# File.basename(path, '.*')
|
64
|
-
# end
|
65
|
-
|
66
55
|
# Use this to run test
|
67
56
|
# Initializes status, runs test, handles exceptions, finalizes status after run completion
|
68
57
|
def run_test
|
@@ -164,14 +153,6 @@ module Moto
|
|
164
153
|
Moto::Lib::Config.environment_const(key)
|
165
154
|
end
|
166
155
|
|
167
|
-
def client(name)
|
168
|
-
Thread.current['clients_manager'].client(name)
|
169
|
-
end
|
170
|
-
|
171
|
-
def session
|
172
|
-
client('Website').session
|
173
|
-
end
|
174
|
-
|
175
156
|
end
|
176
157
|
end
|
177
158
|
end
|
data/lib/test_logging.rb
CHANGED
@@ -12,10 +12,6 @@ module Moto
|
|
12
12
|
|
13
13
|
def cls.method_added(name)
|
14
14
|
|
15
|
-
Moto::EmptyListener.instance_methods(false).each do |m|
|
16
|
-
full_name = "#{self.name}::#{m}"
|
17
|
-
@@ignore_logging << full_name unless @@ignore_logging.include? full_name
|
18
|
-
end
|
19
15
|
@@ignore_logging << "#{self.name}::new"
|
20
16
|
@@ignore_logging << "#{self.name}::initialize"
|
21
17
|
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartek Wilczek
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-
|
14
|
+
date: 2016-09-05 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -86,9 +86,6 @@ files:
|
|
86
86
|
- bin/moto
|
87
87
|
- lib/app_generator.rb
|
88
88
|
- lib/cli.rb
|
89
|
-
- lib/clients/base.rb
|
90
|
-
- lib/clients/clients_manager.rb
|
91
|
-
- lib/clients/website.rb
|
92
89
|
- lib/config.rb
|
93
90
|
- lib/empty_listener.rb
|
94
91
|
- lib/exceptions/moto.rb
|
@@ -96,7 +93,6 @@ files:
|
|
96
93
|
- lib/exceptions/test_forced_passed.rb
|
97
94
|
- lib/exceptions/test_skipped.rb
|
98
95
|
- lib/initializer.rb
|
99
|
-
- lib/page.rb
|
100
96
|
- lib/parser.rb
|
101
97
|
- lib/reporting/listeners/base.rb
|
102
98
|
- lib/reporting/listeners/console.rb
|
data/lib/clients/base.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
module Moto
|
2
|
-
module Clients
|
3
|
-
|
4
|
-
class Base
|
5
|
-
include Moto::EmptyListener
|
6
|
-
|
7
|
-
# include Moto::RunnerLogging
|
8
|
-
include Moto::TestLogging
|
9
|
-
|
10
|
-
ignore_logging(:handle_test_exception)
|
11
|
-
|
12
|
-
def handle_test_exception(test, exception)
|
13
|
-
# abstract
|
14
|
-
end
|
15
|
-
|
16
|
-
# Retrieves specified key's value for current test environment
|
17
|
-
# @param [String] key Key which's value will be returned from merged config files
|
18
|
-
# @return [String] key's value
|
19
|
-
def const(key)
|
20
|
-
Moto::Lib::Config.environment_const(key)
|
21
|
-
end
|
22
|
-
|
23
|
-
# Access client defined in Moto or MotoApp via it's name
|
24
|
-
def client(name)
|
25
|
-
Thread.current['clients_manager'].client(name)
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
module Moto
|
2
|
-
module Lib
|
3
|
-
module Clients
|
4
|
-
class ClientsManager
|
5
|
-
|
6
|
-
attr_reader :clients
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
@clients = {}
|
10
|
-
end
|
11
|
-
|
12
|
-
def client(name)
|
13
|
-
return @clients[name] if @clients.key? name
|
14
|
-
|
15
|
-
name_app = 'MotoApp::Lib::Clients::' + name
|
16
|
-
name_moto = 'Moto::Clients::' + name
|
17
|
-
|
18
|
-
client = try_client(name_app, "#{MotoApp::DIR}/")
|
19
|
-
if client
|
20
|
-
@clients[name] = client
|
21
|
-
return client
|
22
|
-
end
|
23
|
-
|
24
|
-
client = try_client(name_moto, "#{Moto::DIR}/lib/")
|
25
|
-
if client
|
26
|
-
@clients[name] = client
|
27
|
-
return client
|
28
|
-
end
|
29
|
-
|
30
|
-
raise "Could not find client class for name: #{name}"
|
31
|
-
end
|
32
|
-
|
33
|
-
def try_client(name, dir)
|
34
|
-
client_path = name.underscore.split('/')[1..-1].join('/')
|
35
|
-
|
36
|
-
if File.file?(dir + client_path + '.rb')
|
37
|
-
require dir + client_path
|
38
|
-
client_const = name.constantize
|
39
|
-
instance = client_const.new
|
40
|
-
instance.start_run
|
41
|
-
instance
|
42
|
-
else
|
43
|
-
nil
|
44
|
-
end
|
45
|
-
end
|
46
|
-
private :try_client
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
data/lib/clients/website.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
require 'capybara'
|
2
|
-
require 'capybara/poltergeist'
|
3
|
-
require_relative '../../lib/config'
|
4
|
-
|
5
|
-
module Moto
|
6
|
-
module Clients
|
7
|
-
|
8
|
-
class Website < Moto::Clients::Base
|
9
|
-
|
10
|
-
ignore_logging(:session)
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
register_grid_driver
|
14
|
-
register_chrome_driver
|
15
|
-
register_poltergeist_driver
|
16
|
-
|
17
|
-
if config[:default_selector]
|
18
|
-
Capybara.default_selector = config[:default_selector]
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# Returns Capybara session, if none was available for this thread it will create one.
|
23
|
-
def session
|
24
|
-
if Thread.current['capybara_session'].nil?
|
25
|
-
Thread.current['capybara_session'] = Capybara::Session.new(config[:default_driver])
|
26
|
-
Thread.current['capybara_session'].driver.browser.manage.window.maximize
|
27
|
-
end
|
28
|
-
|
29
|
-
Thread.current['capybara_session']
|
30
|
-
end
|
31
|
-
|
32
|
-
# @return [Hash] Config section for Capybara driver.
|
33
|
-
def config
|
34
|
-
Moto::Lib::Config.moto[:clients][:website][:capybara]
|
35
|
-
end
|
36
|
-
private :config
|
37
|
-
|
38
|
-
def start_run
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
def end_run
|
43
|
-
Thread.current['capybara_session'].driver.quit
|
44
|
-
end
|
45
|
-
|
46
|
-
def start_test(test)
|
47
|
-
Thread.current['capybara_session'].reset_session!
|
48
|
-
end
|
49
|
-
|
50
|
-
def end_test(test)
|
51
|
-
Thread.current['capybara_session'].reset_session!
|
52
|
-
end
|
53
|
-
|
54
|
-
def register_grid_driver
|
55
|
-
grid_config = config[:grid]
|
56
|
-
return if grid_config.nil?
|
57
|
-
if grid_config[:capabilities].nil?
|
58
|
-
capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
|
59
|
-
else
|
60
|
-
capabilities = Selenium::WebDriver::Remote::Capabilities.new(grid_config[:capabilities])
|
61
|
-
end
|
62
|
-
Capybara.register_driver :grid do |app|
|
63
|
-
Capybara::Selenium::Driver.new(app,
|
64
|
-
:browser => :remote,
|
65
|
-
:url => grid_config[:url],
|
66
|
-
:desired_capabilities => capabilities)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
private :register_grid_driver
|
70
|
-
|
71
|
-
def register_chrome_driver
|
72
|
-
Capybara.register_driver :chrome do |app|
|
73
|
-
client = Selenium::WebDriver::Remote::Http::Default.new
|
74
|
-
client.timeout = 180
|
75
|
-
caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"args" => [ "-no-sandbox" , "--start-maximized"] })
|
76
|
-
Capybara::Selenium::Driver.new(app, browser: :chrome, http_client: client, desired_capabilities: caps )
|
77
|
-
end
|
78
|
-
end
|
79
|
-
private :register_chrome_driver
|
80
|
-
|
81
|
-
def register_poltergeist_driver
|
82
|
-
#Capybara.javascript_driver = :poltergeist
|
83
|
-
options =
|
84
|
-
{
|
85
|
-
screen_size: [1920,1080],
|
86
|
-
js_errors: false,
|
87
|
-
phantomjs_options: ['--ignore-ssl-errors=yes'],
|
88
|
-
|
89
|
-
}
|
90
|
-
Capybara.register_driver :poltergeist do |app|
|
91
|
-
Capybara::Poltergeist::Driver.new(app, options)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
private :register_poltergeist_driver
|
95
|
-
|
96
|
-
|
97
|
-
def handle_test_exception(test, exception)
|
98
|
-
#Thread.current['capybara_session'].save_screenshot "#{test.dir}/#{test.filename}_#{Time.new.strftime('%Y%m%d_%H%M%S')}.png"
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
data/lib/page.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
module Moto
|
2
|
-
class Page
|
3
|
-
|
4
|
-
include Moto::TestLogging
|
5
|
-
|
6
|
-
ignore_logging :const
|
7
|
-
ignore_logging :session
|
8
|
-
|
9
|
-
# Returns Capybara's session by means of on-the-fly client&session creation.
|
10
|
-
def session
|
11
|
-
Thread.current['clients_manager'].client('Website').session
|
12
|
-
end
|
13
|
-
|
14
|
-
def raise_unless_loaded
|
15
|
-
raise "Invalid state: page #{self.class.name} is not loaded." unless loaded?
|
16
|
-
end
|
17
|
-
|
18
|
-
# Retrieves specified key's value for current test environment
|
19
|
-
# @param [String] key Key which's value will be returned from merged config files
|
20
|
-
# @return [String] key's value
|
21
|
-
def const(key)
|
22
|
-
Moto::Lib::Config.environment_const(key)
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|