kanoah_rspec_formatter 0.1.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 +7 -0
- data/.gitignore +3 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +38 -0
- data/LICENCE +21 -0
- data/README.md +36 -0
- data/kanoah_rspec_formatter.gemspec +23 -0
- data/lib/kanoah_formatter/base_formatter.rb +15 -0
- data/lib/kanoah_result_formatter.rb +67 -0
- data/lib/kanoah_rspec_formatter/adapter.rb +6 -0
- data/lib/kanoah_rspec_formatter/configuration.rb +25 -0
- data/lib/kanoah_rspec_formatter/rspec_steps.rb +15 -0
- data/lib/kanoah_rspec_formatter.rb +5 -0
- data/lib/kanoah_testcase_formatter.rb +79 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 932338c5673f6b2056a561c94971375a8ffbf9c3
|
4
|
+
data.tar.gz: be779697dc4946efb91dbfe9c0a40db32024a3fb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aea6417b8834988f8554ab8ff2440ed06c78cf0d8e7f8d092cf841ae73e4deea47c46356fb9b876607c2f14db59b8e66519aa7c9be7a75a84fd8fd34d34f136f
|
7
|
+
data.tar.gz: 6d3dfd77d13f351e10415a208d9d0c44ed9b5aa6c0a9490ef8cd54e3a343450e2b04ef57c9c0d3a34bceba6aa7c94dde8285788907639a99ae746b22d62920fe
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
kanoah_rspec_formatter (0.1.0)
|
5
|
+
kanoah_ruby (>= 0.1.0)
|
6
|
+
rspec (>= 3.5.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
diff-lcs (1.3)
|
12
|
+
httparty (0.14.0)
|
13
|
+
multi_xml (>= 0.5.2)
|
14
|
+
kanoah_ruby (0.1.0)
|
15
|
+
httparty (>= 0.13.7)
|
16
|
+
multi_xml (0.6.0)
|
17
|
+
rspec (3.5.0)
|
18
|
+
rspec-core (~> 3.5.0)
|
19
|
+
rspec-expectations (~> 3.5.0)
|
20
|
+
rspec-mocks (~> 3.5.0)
|
21
|
+
rspec-core (3.5.4)
|
22
|
+
rspec-support (~> 3.5.0)
|
23
|
+
rspec-expectations (3.5.0)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.5.0)
|
26
|
+
rspec-mocks (3.5.0)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.5.0)
|
29
|
+
rspec-support (3.5.0)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
ruby
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
kanoah_rspec_formatter!
|
36
|
+
|
37
|
+
BUNDLED WITH
|
38
|
+
1.13.6
|
data/LICENCE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT LICENSE
|
2
|
+
|
3
|
+
Copyright (c) Justin Commu <Justin.Commu@loblaw.ca>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Koanoah RSpec Formatter
|
2
|
+
|
3
|
+
Welcome to kanoah_rspec_formatter, a highly opinionated RSpec formatter which communicates test results in realtime to Kanoah
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'kanoah_rpsec_formatter'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install kanoah_rpsec_formatter
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/test. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
32
|
+
|
33
|
+
|
34
|
+
## License
|
35
|
+
|
36
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'kanoah_rspec_formatter'
|
5
|
+
spec.version = '0.1.0'
|
6
|
+
spec.authors = ['Automation Wizards']
|
7
|
+
spec.email = ['Justin.Commu@loblaw.ca']
|
8
|
+
|
9
|
+
spec.summary = ''
|
10
|
+
spec.description = 'A RSpec formatter for Kanoah'
|
11
|
+
spec.homepage = 'https://loblawdigital.ca'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
15
|
+
spec.bindir = 'exe'
|
16
|
+
spec.platform = Gem::Platform::RUBY
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_runtime_dependency 'rspec', '>= 3.5.0'
|
21
|
+
spec.add_runtime_dependency 'kanoah_ruby', '>= 0.1.0'
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rspec/core/formatters/base_formatter'
|
2
|
+
module KanoahRSpecFormatter
|
3
|
+
class BaseFormatter < RSpec::Core::Formatters::BaseFormatter
|
4
|
+
NOTIFICATIONS = [:start, :example_started, :example_passed, :example_failed, :example_pending]
|
5
|
+
|
6
|
+
def start(_notification)
|
7
|
+
@api = Kanoah::Client.new(base_url: KanoahRSpecFormatter::Config.config.base_url,
|
8
|
+
project_id: KanoahRSpecFormatter::Config.config.project_id,
|
9
|
+
test_run_id: KanoahRSpecFormatter::Config.config.test_run_id,
|
10
|
+
environment: KanoahRSpecFormatter::Config.config.environment,
|
11
|
+
username: KanoahRSpecFormatter::Config.config.username,
|
12
|
+
password: KanoahRSpecFormatter::Config.config.password)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require_relative 'kanoah_formatter/base_formatter'
|
2
|
+
class KanoahResultFormatter < KanoahRSpecFormatter::BaseFormatter
|
3
|
+
|
4
|
+
RSpec::Core::Formatters.register self, *NOTIFICATIONS
|
5
|
+
|
6
|
+
def start(notification)
|
7
|
+
super(notification)
|
8
|
+
end
|
9
|
+
|
10
|
+
def example_passed(notification)
|
11
|
+
proccess_result(notification.example) if notification.example.metadata.has_key?(:test_id) && !test_id(notification.example).empty?
|
12
|
+
end
|
13
|
+
|
14
|
+
def example_failed(notification)
|
15
|
+
proccess_result(notification.example) if notification.example.metadata.has_key?(:test_id) && !test_id(notification.example).empty?
|
16
|
+
end
|
17
|
+
|
18
|
+
def example_pending(notification)
|
19
|
+
proccess_result(notification.example) if notification.example.metadata.has_key?(:test_id) && !test_id(notification.example).empty?
|
20
|
+
end
|
21
|
+
|
22
|
+
def example_started(notification)
|
23
|
+
notification.example.metadata[:step_index] = 0
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def proccess_result(example)
|
29
|
+
body = {
|
30
|
+
test_case: test_id(example),
|
31
|
+
status: status(example.metadata[:execution_result]),
|
32
|
+
comment: comment(example.metadata),
|
33
|
+
execution_time: run_time(example.metadata[:execution_result]),
|
34
|
+
script_results: steps(example.metadata)
|
35
|
+
}
|
36
|
+
@api.test_run_id ? @api.post_new_result_to_run(body) : @api.post_new_result(body)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_id(example)
|
40
|
+
example.metadata[:test_id]
|
41
|
+
end
|
42
|
+
|
43
|
+
def status(scenario)
|
44
|
+
status_code(scenario.status)
|
45
|
+
end
|
46
|
+
|
47
|
+
def run_time(scenario)
|
48
|
+
scenario.run_time.to_i * 1000
|
49
|
+
end
|
50
|
+
|
51
|
+
def comment(scenario)
|
52
|
+
scenario[:kanoah_evidence][:title] + "\n" + scenario[:kanoah_evidence][:path] unless scenario[:kanoah_evidence].nil?
|
53
|
+
end
|
54
|
+
|
55
|
+
def steps(scenario)
|
56
|
+
scenario[:steps]
|
57
|
+
end
|
58
|
+
|
59
|
+
def status_code(status)
|
60
|
+
case status
|
61
|
+
when :failed, :passed then
|
62
|
+
status.to_s.gsub('ed', '').capitalize
|
63
|
+
when :pending then
|
64
|
+
'Blocked'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module KanoahRSpecFormatter
|
2
|
+
module Config
|
3
|
+
class << self
|
4
|
+
attr_accessor :config
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.configure
|
8
|
+
self.config ||= Configuration.new
|
9
|
+
yield(config)
|
10
|
+
end
|
11
|
+
|
12
|
+
class Configuration
|
13
|
+
attr_accessor :base_url, :test_run_id, :environment, :username, :password, :project_id
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@base_url = nil
|
17
|
+
@test_run_id = nil
|
18
|
+
@project_id = nil
|
19
|
+
@environment = nil
|
20
|
+
@username = nil
|
21
|
+
@password = nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module KanoahRSpecFormatter
|
2
|
+
module Example
|
3
|
+
def step(_step, options = {}, &block)
|
4
|
+
@metadata[:steps] = [] if @metadata[:steps].nil?
|
5
|
+
begin
|
6
|
+
yield block
|
7
|
+
@metadata[:steps].push({ index: @metadata[:step_index], status: 'Pass' })
|
8
|
+
rescue Exception => e
|
9
|
+
@exception = e
|
10
|
+
@metadata[:steps].push({ index: @metadata[:step_index], status: 'Fail', comment: e })
|
11
|
+
end
|
12
|
+
@metadata[:step_index] += 1 if @metadata.has_key?(:step_index)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require_relative 'kanoah_formatter/base_formatter'
|
2
|
+
class KanoahTestcaseFormatter < KanoahRSpecFormatter::BaseFormatter
|
3
|
+
|
4
|
+
RSpec::Core::Formatters.register self, *NOTIFICATIONS
|
5
|
+
|
6
|
+
def start(notification)
|
7
|
+
super(notification)
|
8
|
+
end
|
9
|
+
|
10
|
+
def example_passed(notification)
|
11
|
+
proccess_result(notification.example)
|
12
|
+
end
|
13
|
+
|
14
|
+
def example_pending(notification)
|
15
|
+
proccess_result(notification.example)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def proccess_result(example)
|
21
|
+
|
22
|
+
test_id = @api.post_new_test_case(testcase_body(example))
|
23
|
+
# @api.post_new_result_to_run(body)
|
24
|
+
update_exomple(example, test_id)
|
25
|
+
end
|
26
|
+
|
27
|
+
def testcase_body(example)
|
28
|
+
{
|
29
|
+
projectKey: project_key(example),
|
30
|
+
name: description(example),
|
31
|
+
folder: '',
|
32
|
+
status: '',
|
33
|
+
priority: '',
|
34
|
+
component: '',
|
35
|
+
labels: '',
|
36
|
+
testScript: ''
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def project_key(example)
|
41
|
+
example[:project]
|
42
|
+
end
|
43
|
+
|
44
|
+
def description(example)
|
45
|
+
example[:description]
|
46
|
+
end
|
47
|
+
|
48
|
+
def update_example(example, test_id)
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# def post_new_test_case(body)
|
54
|
+
# @response = self.class.post("/rest/kanoahtests/1.0/testcase", body: body.to_json, headers: @header)
|
55
|
+
# self
|
56
|
+
# end
|
57
|
+
|
58
|
+
# {
|
59
|
+
# "projectKey": "JQA",
|
60
|
+
# "name": "Ensure the axial-flow pump is enabled",
|
61
|
+
# "precondition": "The precondition.",
|
62
|
+
# "objective": "The objective.",
|
63
|
+
# "folder": "/Orbiter/Cargo Bay",
|
64
|
+
# "status": "Approved",
|
65
|
+
# "priority": "Low",
|
66
|
+
# "component": "Valves",
|
67
|
+
# "owner": "vitor.pelizza",
|
68
|
+
# "estimatedTime": 138000,
|
69
|
+
# "labels": ["Smoke", "Functional"],
|
70
|
+
# "testScript": {
|
71
|
+
# "type": "STEP_BY_STEP",
|
72
|
+
# "steps": [
|
73
|
+
# {
|
74
|
+
# "description": "Ignite the secondary propulsion engines.",
|
75
|
+
# "expectedResult": "Ensure the high-pressure combustion chamber's pressure is around 3000 psi."
|
76
|
+
# }
|
77
|
+
# ]
|
78
|
+
# }
|
79
|
+
# }
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kanoah_rspec_formatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Automation Wizards
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.5.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.5.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: kanoah_ruby
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.0
|
41
|
+
description: A RSpec formatter for Kanoah
|
42
|
+
email:
|
43
|
+
- Justin.Commu@loblaw.ca
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- LICENCE
|
52
|
+
- README.md
|
53
|
+
- kanoah_rspec_formatter.gemspec
|
54
|
+
- lib/kanoah_formatter/base_formatter.rb
|
55
|
+
- lib/kanoah_result_formatter.rb
|
56
|
+
- lib/kanoah_rspec_formatter.rb
|
57
|
+
- lib/kanoah_rspec_formatter/adapter.rb
|
58
|
+
- lib/kanoah_rspec_formatter/configuration.rb
|
59
|
+
- lib/kanoah_rspec_formatter/rspec_steps.rb
|
60
|
+
- lib/kanoah_testcase_formatter.rb
|
61
|
+
homepage: https://loblawdigital.ca
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.6.7
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: ''
|
85
|
+
test_files: []
|