rspec-testrail 0.1.0 → 0.1.1
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/Gemfile +2 -0
- data/README.md +16 -4
- data/lib/rspec/testrail/client.rb +3 -1
- data/lib/rspec/testrail/version.rb +1 -1
- data/lib/rspec/testrail.rb +60 -0
- data/rspec-testrail.gemspec +1 -0
- metadata +15 -2
- data/lib/rspec/testrail/configuration.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f3cf3e0ea8759d4ce3b9716ef21786244277c1f
|
4
|
+
data.tar.gz: 72cdfb8d97e88d9427b4be4ab0dc84829428fdd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86fa169d8f3eb4bca53bc9045448b36995191cdaae09fde8d9c1d3bff4bb11338e173605701cdae78802dddf13e7fcfabb65ca82ab798eaf03e536f22842c459
|
7
|
+
data.tar.gz: 3e1d1278578c13a00ec5d919bbbf4591b3f9d3f42bae15dbbc6a5a51b62ebb546a18ea98257f42c59a39bd528a04e668fcfa48d2023779a53ba9c89da2de50a0
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -25,10 +25,22 @@ Or install it yourself as:
|
|
25
25
|
require 'rspec/testrail'
|
26
26
|
|
27
27
|
RSpec.configure do |config|
|
28
|
-
|
29
|
-
config.
|
30
|
-
|
31
|
-
|
28
|
+
|
29
|
+
config.before :all do
|
30
|
+
# Uncomment if you are using gem `webmock`
|
31
|
+
# WebMock.allow_net_connect!
|
32
|
+
RSpec::Testrail.init url: 'http://test.site',
|
33
|
+
user: 'test@test.site',
|
34
|
+
password: ENV.fetch('TESTRAIL_PASSWORD', '12345678'),
|
35
|
+
project_id: 228,
|
36
|
+
suite_id: 1337
|
37
|
+
end
|
38
|
+
|
39
|
+
config.after :example, testrail_id: proc { |value| !value.nil? } do |example|
|
40
|
+
# Uncomment if you are using gem `webmock`
|
41
|
+
# WebMock.allow_net_connect!
|
42
|
+
RSpec::Testrail.process(example)
|
43
|
+
end
|
32
44
|
end
|
33
45
|
```
|
34
46
|
|
@@ -24,9 +24,11 @@ module RSpec
|
|
24
24
|
attr_accessor :user
|
25
25
|
attr_accessor :password
|
26
26
|
|
27
|
-
def initialize(base_url)
|
27
|
+
def initialize(base_url, user, password)
|
28
28
|
base_url += '/' unless base_url =~ %r{/\/$/}
|
29
29
|
@url = base_url + 'index.php?/api/v2/'
|
30
|
+
@user = user
|
31
|
+
@password = password
|
30
32
|
end
|
31
33
|
|
32
34
|
#
|
data/lib/rspec/testrail.rb
CHANGED
@@ -3,5 +3,65 @@ require 'rspec/testrail/client'
|
|
3
3
|
|
4
4
|
module RSpec
|
5
5
|
module Testrail
|
6
|
+
class << self
|
7
|
+
attr_reader :options
|
8
|
+
|
9
|
+
def init(hash = {})
|
10
|
+
@options = {
|
11
|
+
url: hash[:url],
|
12
|
+
user: hash[:user],
|
13
|
+
password: hash[:password],
|
14
|
+
project_id: hash[:project_id],
|
15
|
+
suite_id: hash[:suite_id],
|
16
|
+
git_revision: `git rev-parse HEAD`.strip,
|
17
|
+
git_branch: `git rev-parse --abbrev-ref HEAD`.strip
|
18
|
+
}
|
19
|
+
client
|
20
|
+
end
|
21
|
+
|
22
|
+
def client
|
23
|
+
@client ||= Client.new(@options[:url], @options[:user], @options[:password])
|
24
|
+
end
|
25
|
+
|
26
|
+
def reset_client
|
27
|
+
@client = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def process(example)
|
31
|
+
if example.exception
|
32
|
+
status = 5
|
33
|
+
message = example.exception.message
|
34
|
+
else
|
35
|
+
status = 1
|
36
|
+
message = ''
|
37
|
+
end
|
38
|
+
client.send_post("add_result_for_case/#{testrun['id']}/#{example.metadata[:testrail_id]}",
|
39
|
+
status_id: status,
|
40
|
+
comment: message)
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
def testrun
|
46
|
+
@testrun ||=
|
47
|
+
if testruns.empty?
|
48
|
+
client.send_post("add_run/#{@options[:project_id]}",
|
49
|
+
suite_id: @options[:suite_id],
|
50
|
+
name: "Test run for #{@options[:git_branch]}",
|
51
|
+
description: "Revision: #{@options[:git_revision]}")
|
52
|
+
else
|
53
|
+
client.send_post("update_run/#{testruns[0]['id']}",
|
54
|
+
description: "Revision: #{@options[:git_revision]}")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def testruns
|
59
|
+
@testruns ||= client.send_get("get_runs/#{@options[:project_id]}")
|
60
|
+
.select do |run|
|
61
|
+
run['suite_id'] == @options[:suite_id].to_i && \
|
62
|
+
run['name'].include?(@options[:git_branch])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
6
66
|
end
|
7
67
|
end
|
data/rspec-testrail.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-testrail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Zuev
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: webmock
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.1'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,7 +87,6 @@ files:
|
|
73
87
|
- bin/setup
|
74
88
|
- lib/rspec/testrail.rb
|
75
89
|
- lib/rspec/testrail/client.rb
|
76
|
-
- lib/rspec/testrail/configuration.rb
|
77
90
|
- lib/rspec/testrail/version.rb
|
78
91
|
- rspec-testrail.gemspec
|
79
92
|
homepage: https://github.com/dmitryzuev/rspec-testrail
|