rspec-testrail 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0fe3984c32800442ea6a2a5f09dac8cb469ff340
4
- data.tar.gz: e3b94235a0f1115faf4e090b5874faaaabda6c3a
3
+ metadata.gz: 2f3cf3e0ea8759d4ce3b9716ef21786244277c1f
4
+ data.tar.gz: 72cdfb8d97e88d9427b4be4ab0dc84829428fdd1
5
5
  SHA512:
6
- metadata.gz: 10a9d64953c007eba353d420e57497ca2f0d4b00ce1739f22c02a1283e12cfec794062431f3d8f3b3fe1aade557856a9b2922b0748d864bdc408f014ad3ebcb4
7
- data.tar.gz: e5db9597281162d22e9fc107d54189b78c81963b7716e01e8002e8a7d1fe1a190da8a39d34ac67b7cc457c4198ebdbb4550f7cc350891ec1e36932459ff9bcf5
6
+ metadata.gz: 86fa169d8f3eb4bca53bc9045448b36995191cdaae09fde8d9c1d3bff4bb11338e173605701cdae78802dddf13e7fcfabb65ca82ab798eaf03e536f22842c459
7
+ data.tar.gz: 3e1d1278578c13a00ec5d919bbbf4591b3f9d3f42bae15dbbc6a5a51b62ebb546a18ea98257f42c59a39bd528a04e668fcfa48d2023779a53ba9c89da2de50a0
data/Gemfile CHANGED
@@ -4,3 +4,5 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'rubocop'
7
+ gem 'awesome_print'
8
+ gem 'pry'
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
- config.include RSpec::Testrail::Configuration
29
- config.testrail.url = 'http://testrail.dev/'
30
- config.testrail.user = 'tester@testrail.dev'
31
- config.testrail.password = ENV.fetch('TESTRAIL_PASSWORD', '')
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
  #
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module Testrail
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.1.1'.freeze
4
4
  end
5
5
  end
@@ -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
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency 'bundler', '~> 1.12'
24
24
  spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'webmock', '~> 2.1'
25
26
 
26
27
  spec.add_runtime_dependency 'rspec', '~> 3.0'
27
28
  end
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.0
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
@@ -1,6 +0,0 @@
1
- module RSpec
2
- module Testrail
3
- class Configuration
4
- end
5
- end
6
- end