moto 0.0.27 → 0.0.28

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6340ddcd3b7bd29181c132c770e511ff057e7f65
4
- data.tar.gz: 61b04ec015807b80fd7534b0df79675bfe341b1e
3
+ metadata.gz: 09f0234bb00b4a41be50adc245e68b64f7607a30
4
+ data.tar.gz: 826f121bea84c24f1acbc88268f893266a92103a
5
5
  SHA512:
6
- metadata.gz: 3b6d8ab0b350eee5e36020dc1fd290153f93761d2e09d167835b39ddd6f80395f86a98c584924a03d3dc7d8df5b8109c00839e83cfa6d1b1813f249b586cfb86
7
- data.tar.gz: 9216bef294eefd81da2c88139ee1065f535365bfc5d09b6ff5e81dc43c63510f5e89f05ff7eed7c54e6eb16d7b9892d2d3c88de72e2c417f8b6bb6968d5e90cd
6
+ metadata.gz: a219594402982571615b0712656d2de4a7cd60bd1165eb3690fb325faa97e96a5328a60bcb010a6c145025c2fef6fdb57051a4e0ce89933333229de2fa672c65
7
+ data.tar.gz: 42844bb00bdeb41c20b8e67041625d02d42bb82cf95bb9c553ea487c4a74f6dd7cac5951718a880239ac978452aa4adf501dbfa2f0effbe7cf7bd77c125e3c3c
@@ -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
@@ -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
@@ -1,21 +1,21 @@
1
- module Moto
2
- module ForwardContextMethods
3
-
4
- def client(name)
5
- @context.client(name)
6
- end
7
-
8
- def logger
9
- @context.logger
10
- end
11
-
12
- def const(key)
13
- @context.const(key)
14
- end
15
-
16
- def current_test
17
- @context.current_test
18
- end
19
-
20
- end
1
+ module Moto
2
+ module ForwardContextMethods
3
+
4
+ def client(name)
5
+ @context.client(name)
6
+ end
7
+
8
+ def logger
9
+ @context.logger
10
+ end
11
+
12
+ def const(key)
13
+ @context.const(key)
14
+ end
15
+
16
+ def current_test
17
+ @context.current_test
18
+ end
19
+
20
+ end
21
21
  end
@@ -1,26 +1,26 @@
1
- module Moto
2
- module Listeners
3
- class Base
4
-
5
- def initialize(runner)
6
- @runner=runner
7
- end
8
-
9
- def start_run
10
- # abstract
11
- end
12
-
13
- def end_run
14
- # abstract
15
- end
16
-
17
- def start_test(test)
18
- # abstract
19
- end
20
-
21
- def end_test(test)
22
- # abstract
23
- end
24
- end
25
- end
1
+ module Moto
2
+ module Listeners
3
+ class Base
4
+
5
+ def initialize(runner)
6
+ @runner=runner
7
+ end
8
+
9
+ def start_run
10
+ # abstract
11
+ end
12
+
13
+ def end_run
14
+ # abstract
15
+ end
16
+
17
+ def start_test(test)
18
+ # abstract
19
+ end
20
+
21
+ def end_test(test)
22
+ # abstract
23
+ end
24
+ end
25
+ end
26
26
  end
@@ -1,29 +1,29 @@
1
- module Moto
2
- module Listeners
3
- class Console < Base
4
-
5
- def start_run
6
- puts "START"
7
- end
8
-
9
- def end_run
10
- puts ""
11
- puts "FINISHED: #{@runner.result.summary[:result]}, duration: #{Time.at(@runner.result.summary[:duration]).utc.strftime("%H:%M:%S")}"
12
- puts "Tests executed: #{@runner.result.summary[:cnt_all]}"
13
- puts " Passed: #{@runner.result.summary[:cnt_passed]}"
14
- puts " Failure: #{@runner.result.summary[:cnt_failure]}"
15
- puts " Error: #{@runner.result.summary[:cnt_error]}"
16
- puts " Skipped: #{@runner.result.summary[:cnt_skipped]}"
17
- end
18
-
19
- def start_test(test)
20
- print test.name
21
- end
22
-
23
- def end_test(test)
24
- puts "\t#{@runner.result[test.name][:result]}"
25
- end
26
-
27
- end
28
- end
1
+ module Moto
2
+ module Listeners
3
+ class Console < Base
4
+
5
+ def start_run
6
+ puts "START"
7
+ end
8
+
9
+ def end_run
10
+ puts ""
11
+ puts "FINISHED: #{@runner.result.summary[:result]}, duration: #{Time.at(@runner.result.summary[:duration]).utc.strftime("%H:%M:%S")}"
12
+ puts "Tests executed: #{@runner.result.summary[:cnt_all]}"
13
+ puts " Passed: #{@runner.result.summary[:cnt_passed]}"
14
+ puts " Failure: #{@runner.result.summary[:cnt_failure]}"
15
+ puts " Error: #{@runner.result.summary[:cnt_error]}"
16
+ puts " Skipped: #{@runner.result.summary[:cnt_skipped]}"
17
+ end
18
+
19
+ def start_test(test)
20
+ print test.name
21
+ end
22
+
23
+ def end_test(test)
24
+ puts "\t#{@runner.result[test.name][:result]}"
25
+ end
26
+
27
+ end
28
+ end
29
29
  end
@@ -1,37 +1,37 @@
1
- require 'nokogiri'
2
-
3
- module Moto
4
- module Listeners
5
- class JunitXml < Base
6
-
7
- def end_run
8
- path = @runner.my_config[:output_file]
9
-
10
- builder = Nokogiri::XML::Builder.new { |xml|
11
- xml.testsuite(
12
- errors: @runner.result.summary[:cnt_error],
13
- failures: @runner.result.summary[:cnt_failure],
14
- name: "Moto run",
15
- tests: @runner.result.summary[:cnt_all],
16
- time: @runner.result.summary[:duration],
17
- timestamp: Time.at(@runner.result.summary[:started_at])) do
18
- @runner.result.all.each do |test_name, data|
19
- xml.testcase(name: test_name, time: data[:duration], classname: data[:class].name, moto_result: data[:result]) do
20
- if !data[:error].nil?
21
- xml.error(message: data[:error].message)
22
- elsif data[:failures].count > 0
23
- data[:failures].each do |f|
24
- xml.failure(message: f)
25
- end
26
- end
27
- end
28
- end
29
- end
30
- }
31
-
32
- File.open(path, 'w') {|f| f.write(builder.to_xml) }
33
- end
34
-
35
- end
36
- end
1
+ require 'nokogiri'
2
+
3
+ module Moto
4
+ module Listeners
5
+ class JunitXml < Base
6
+
7
+ def end_run
8
+ path = @runner.my_config[:output_file]
9
+
10
+ builder = Nokogiri::XML::Builder.new { |xml|
11
+ xml.testsuite(
12
+ errors: @runner.result.summary[:cnt_error],
13
+ failures: @runner.result.summary[:cnt_failure],
14
+ name: "Moto run",
15
+ tests: @runner.result.summary[:cnt_all],
16
+ time: @runner.result.summary[:duration],
17
+ timestamp: Time.at(@runner.result.summary[:started_at])) do
18
+ @runner.result.all.each do |test_name, data|
19
+ xml.testcase(name: test_name, time: data[:duration], classname: data[:class].name, moto_result: data[:result]) do
20
+ if !data[:error].nil?
21
+ xml.error(message: data[:error].message)
22
+ elsif data[:failures].count > 0
23
+ data[:failures].each do |f|
24
+ xml.failure(message: f)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ }
31
+
32
+ File.open(path, 'w') {|f| f.write(builder.to_xml) }
33
+ end
34
+
35
+ end
36
+ end
37
37
  end
@@ -1,71 +1,71 @@
1
- require 'rest-client'
2
- require 'sys/uname'
3
-
4
- module Moto
5
- module Listeners
6
- class Webui < Base
7
-
8
- def start_run
9
- # POST http://sandbox.dev:3000/api/runs/create
10
- @url = @runner.my_config[:url]
11
- data = {
12
- name: @runner.name,
13
- result: Moto::Result::RUNNING,
14
- cnt_all: nil,
15
- cnt_passed: nil,
16
- cnt_failure: nil,
17
- cnt_error: nil,
18
- cnt_skipped: nil,
19
- user: Sys::Uname.sysname.downcase.include?('windows') ? ENV['USERNAME'] : ENV['LOGNAME'],
20
- host: Sys::Uname.nodename,
21
- pid: Process.pid
22
- }
23
- @run = JSON.parse( RestClient.post( "#{@url}/api/runs", data.to_json, :content_type => :json, :accept => :json ) )
24
- @tests = {}
25
- end
26
-
27
- def end_run
28
- # PUT http://sandbox.dev:3000/api/runs/1
29
- data = {
30
- result: @runner.result.summary[:result],
31
- cnt_all: @runner.result.summary[:cnt_all],
32
- cnt_passed: @runner.result.summary[:cnt_passed],
33
- cnt_failure: @runner.result.summary[:cnt_failure],
34
- cnt_error: @runner.result.summary[:cnt_error],
35
- cnt_skipped: @runner.result.summary[:cnt_skipped],
36
- duration: @runner.result.summary[:duration]
37
- }
38
- @run = JSON.parse( RestClient.put( "#{@url}/api/runs/#{@run['id']}", data.to_json, :content_type => :json, :accept => :json ) )
39
- end
40
-
41
- def start_test(test)
42
- # POST http://sandbox.dev:3000/api/tests/create
43
- data = {
44
- name: test.name,
45
- class_name: test.class.name,
46
- log: nil,
47
- run_id: @run['id'],
48
- env: test.env,
49
- parameters: test.params.to_s,
50
- result: Moto::Result::RUNNING,
51
- error: nil,
52
- failures: nil,
53
- }
54
- @tests[test.name] = JSON.parse( RestClient.post( "#{@url}/api/tests", data.to_json, :content_type => :json, :accept => :json ) )
55
- end
56
-
57
- def end_test(test)
58
- log = File.read(test.log_path)
59
- data = {
60
- log: log,
61
- result: @runner.result[test.name][:result],
62
- error: @runner.result[test.name][:error].nil? ? nil : @runner.result[test.name][:error].message,
63
- failures: @runner.result[test.name][:failures].join("\n\t"),
64
- duration: @runner.result[test.name][:duration]
65
- }
66
- @tests[test.name] = JSON.parse( RestClient.put( "#{@url}/api/tests/#{@tests[test.name]['id']}", data.to_json, :content_type => :json, :accept => :json ) )
67
- end
68
-
69
- end
70
- end
1
+ require 'rest-client'
2
+ require 'sys/uname'
3
+
4
+ module Moto
5
+ module Listeners
6
+ class Webui < Base
7
+
8
+ def start_run
9
+ # POST http://sandbox.dev:3000/api/runs/create
10
+ @url = @runner.my_config[:url]
11
+ data = {
12
+ name: @runner.name,
13
+ result: Moto::Result::RUNNING,
14
+ cnt_all: nil,
15
+ cnt_passed: nil,
16
+ cnt_failure: nil,
17
+ cnt_error: nil,
18
+ cnt_skipped: nil,
19
+ user: Sys::Uname.sysname.downcase.include?('windows') ? ENV['USERNAME'] : ENV['LOGNAME'],
20
+ host: Sys::Uname.nodename,
21
+ pid: Process.pid
22
+ }
23
+ @run = JSON.parse( RestClient.post( "#{@url}/api/runs", data.to_json, :content_type => :json, :accept => :json ) )
24
+ @tests = {}
25
+ end
26
+
27
+ def end_run
28
+ # PUT http://sandbox.dev:3000/api/runs/1
29
+ data = {
30
+ result: @runner.result.summary[:result],
31
+ cnt_all: @runner.result.summary[:cnt_all],
32
+ cnt_passed: @runner.result.summary[:cnt_passed],
33
+ cnt_failure: @runner.result.summary[:cnt_failure],
34
+ cnt_error: @runner.result.summary[:cnt_error],
35
+ cnt_skipped: @runner.result.summary[:cnt_skipped],
36
+ duration: @runner.result.summary[:duration]
37
+ }
38
+ @run = JSON.parse( RestClient.put( "#{@url}/api/runs/#{@run['id']}", data.to_json, :content_type => :json, :accept => :json ) )
39
+ end
40
+
41
+ def start_test(test)
42
+ # POST http://sandbox.dev:3000/api/tests/create
43
+ data = {
44
+ name: test.name,
45
+ class_name: test.class.name,
46
+ log: nil,
47
+ run_id: @run['id'],
48
+ env: test.env,
49
+ parameters: test.params.to_s,
50
+ result: Moto::Result::RUNNING,
51
+ error: nil,
52
+ failures: nil,
53
+ }
54
+ @tests[test.name] = JSON.parse( RestClient.post( "#{@url}/api/tests", data.to_json, :content_type => :json, :accept => :json ) )
55
+ end
56
+
57
+ def end_test(test)
58
+ log = File.read(test.log_path)
59
+ data = {
60
+ log: log,
61
+ result: @runner.result[test.name][:result],
62
+ error: @runner.result[test.name][:error].nil? ? nil : @runner.result[test.name][:error].message,
63
+ failures: @runner.result[test.name][:failures].join("\n\t"),
64
+ duration: @runner.result[test.name][:duration]
65
+ }
66
+ @tests[test.name] = JSON.parse( RestClient.put( "#{@url}/api/tests/#{@tests[test.name]['id']}", data.to_json, :content_type => :json, :accept => :json ) )
67
+ end
68
+
69
+ end
70
+ end
71
71
  end
data/lib/parser.rb CHANGED
@@ -10,14 +10,17 @@ module Moto
10
10
 
11
11
  def self.run(argv)
12
12
  begin
13
- # TODO Generate app / Change the way parsing options goes so it doesnt generate them if they`re not needed
14
- case argv[0]
15
- when '--version' then puts Moto::VERSION
16
- when 'run' then Moto::Cli.run(run_parse(argv))
17
- when 'help' then show_help
18
- when 'generate' then Moto::AppGenerator.run(generate_parse(argv))
19
- else puts "Command '#{argv[0]}' not recognized. Type help for list of supported commands."
13
+
14
+ if argv[0] == '--version'
15
+ puts Moto::VERSION
16
+ elsif argv[0] == 'run' && argv.length > 1
17
+ Moto::Cli.run(run_parse(argv))
18
+ elsif argv[0] == 'generate' && argv.length > 1
19
+ Moto::AppGenerator.run(generate_parse(argv))
20
+ else
21
+ show_help
20
22
  end
23
+
21
24
  rescue Exception => e
22
25
  puts e.message
23
26
  end
@@ -1,27 +1,27 @@
1
- module Moto
2
- module RunnerLogging
3
-
4
-
5
- # TODO: merge it somehow with TestLogging. Parametrize logger object?
6
- def self.included(cls)
7
- def cls.method_added(name)
8
- excluded_methods = Moto::EmptyListener.instance_methods(false)
9
- excluded_methods << :new
10
- excluded_methods << :initialize
11
- # TODO: configure more excluded classes/methods
12
- return if @added
13
- @added = true # protect from recursion
14
- original_method = "original_#{name}"
15
- alias_method original_method, name
16
- define_method(name) do |*args|
17
- @context.runner.logger.debug("#{self.class.name}::#{__callee__} ENTER >>> #{args}") unless excluded_methods.include? name
18
- result = send original_method, *args
19
- @context.runner.logger.debug("#{self.class.name}::#{__callee__} LEAVE <<< #{result} ") unless excluded_methods.include? name
20
- result
21
- end
22
- @added = false
23
- end
24
-
25
- end
26
- end
1
+ module Moto
2
+ module RunnerLogging
3
+
4
+
5
+ # TODO: merge it somehow with TestLogging. Parametrize logger object?
6
+ def self.included(cls)
7
+ def cls.method_added(name)
8
+ excluded_methods = Moto::EmptyListener.instance_methods(false)
9
+ excluded_methods << :new
10
+ excluded_methods << :initialize
11
+ # TODO: configure more excluded classes/methods
12
+ return if @added
13
+ @added = true # protect from recursion
14
+ original_method = "original_#{name}"
15
+ alias_method original_method, name
16
+ define_method(name) do |*args|
17
+ @context.runner.logger.debug("#{self.class.name}::#{__callee__} ENTER >>> #{args}") unless excluded_methods.include? name
18
+ result = send original_method, *args
19
+ @context.runner.logger.debug("#{self.class.name}::#{__callee__} LEAVE <<< #{result} ") unless excluded_methods.include? name
20
+ result
21
+ end
22
+ @added = false
23
+ end
24
+
25
+ end
26
+ end
27
27
  end
data/lib/test_logging.rb CHANGED
@@ -1,49 +1,49 @@
1
- module Moto
2
- module TestLogging
3
-
4
- @@ignore_logging = []
5
-
6
- def self.included(cls)
7
-
8
- def cls.ignore_logging(method)
9
- full_name = "#{self.name}::#{method}"
10
- @@ignore_logging << full_name
11
- end
12
-
13
- def cls.method_added(name)
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
- @@ignore_logging << "#{self.name}::new"
20
- @@ignore_logging << "#{self.name}::initialize"
21
-
22
- return if @added
23
- @added = true # protect from recursion
24
- original_method = "original_#{name}"
25
- alias_method original_method, name
26
- define_method(name) do |*args|
27
- full_name = "#{self.class.name}::#{__callee__}"
28
- # TODO: use self.class.ancestors to figure out if ancestor::__callee__ is not in @@ignore_logging
29
- skip_logging = @@ignore_logging.include? full_name
30
- unless skip_logging
31
- self.class.ancestors.each do |a|
32
- ancestor_name = "#{a.name}::#{__callee__}"
33
- if @@ignore_logging.include? ancestor_name
34
- skip_logging = true
35
- break
36
- end
37
- end
38
- end
39
- @context.current_test.logger.debug("ENTER >>> #{self.class.name}::#{__callee__}(#{args})") unless skip_logging
40
- result = send original_method, *args
41
- @context.current_test.logger.debug("LEAVE <<< #{self.class.name}::#{__callee__} => #{result} ") unless skip_logging
42
- result
43
- end
44
- @added = false
45
- end
46
- end
47
-
48
- end
1
+ module Moto
2
+ module TestLogging
3
+
4
+ @@ignore_logging = []
5
+
6
+ def self.included(cls)
7
+
8
+ def cls.ignore_logging(method)
9
+ full_name = "#{self.name}::#{method}"
10
+ @@ignore_logging << full_name
11
+ end
12
+
13
+ def cls.method_added(name)
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
+ @@ignore_logging << "#{self.name}::new"
20
+ @@ignore_logging << "#{self.name}::initialize"
21
+
22
+ return if @added
23
+ @added = true # protect from recursion
24
+ original_method = "original_#{name}"
25
+ alias_method original_method, name
26
+ define_method(name) do |*args|
27
+ full_name = "#{self.class.name}::#{__callee__}"
28
+ # TODO: use self.class.ancestors to figure out if ancestor::__callee__ is not in @@ignore_logging
29
+ skip_logging = @@ignore_logging.include? full_name
30
+ unless skip_logging
31
+ self.class.ancestors.each do |a|
32
+ ancestor_name = "#{a.name}::#{__callee__}"
33
+ if @@ignore_logging.include? ancestor_name
34
+ skip_logging = true
35
+ break
36
+ end
37
+ end
38
+ end
39
+ @context.current_test.logger.debug("ENTER >>> #{self.class.name}::#{__callee__}(#{args})") unless skip_logging
40
+ result = send original_method, *args
41
+ @context.current_test.logger.debug("LEAVE <<< #{self.class.name}::#{__callee__} => #{result} ") unless skip_logging
42
+ result
43
+ end
44
+ @added = false
45
+ end
46
+ end
47
+
48
+ end
49
49
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Moto
2
- VERSION = '0.0.27'
2
+ VERSION = '0.0.28'
3
3
  end
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.27
4
+ version: 0.0.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartek Wilczek
8
8
  - Maciej Stark
9
9
  - Radosław Sporny
10
+ - Michał Kujawski
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2016-03-01 00:00:00.000000000 Z
14
+ date: 2016-03-02 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: activesupport
@@ -76,6 +77,7 @@ email:
76
77
  - bwilczek@gmail.com
77
78
  - stark.maciej@gmail.com
78
79
  - r.sporny@gmail.com
80
+ - michal.kujawski@gmail.com
79
81
  executables:
80
82
  - moto
81
83
  extensions: []
@@ -130,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
132
  version: '0'
131
133
  requirements: []
132
134
  rubyforge_project:
133
- rubygems_version: 2.2.5
135
+ rubygems_version: 2.4.5.1
134
136
  signing_key:
135
137
  specification_version: 4
136
138
  summary: Moto - yet another web testing framework