rspec-testrail-jamesdphillips 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: abde3aba69ddc6cae242a6ff057c2d4e380a5a9f7426e02848e5a16c9862e8c1
4
+ data.tar.gz: 4622414a916cbf2cfc307b2a6a9fc13e98c3d8bb5c3782973c2f95a285a4e4af
5
+ SHA512:
6
+ metadata.gz: 34629d2d17312956f84baa2369c4a5a8304f0cea8e0d66c68e5b6dc9e7b4f009e52c7eaf5de94734f3564784ee04c3cea6c8426d0717430b0a412f178a376d9d
7
+ data.tar.gz: 68cfb6abd3a1351035066fecc0e78fe7eddb599c26df00ba0f2b6750c37dfd9ca17ca20fa1d251825bbbfb2e4e099adb6764470258a313c59f4e69d0c83f7002
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,24 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+
4
+ Exclude:
5
+ - 'bin/**/*'
6
+ - 'tmp/**/*'
7
+ - 'test/test_helper.rb'
8
+ - 'spec/spec_helper.rb'
9
+ - 'spec/rails_helper.rb'
10
+
11
+ Metrics/LineLength:
12
+ Max: 100
13
+
14
+ Metrics/MethodLength:
15
+ Max: 20
16
+
17
+ Style/BlockComments:
18
+ Enabled: false
19
+
20
+ Style/FrozenStringLiteralComment:
21
+ Enabled: false
22
+
23
+ Documentation:
24
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.1
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.0.0
5
+ - 2.2
6
+ - 2.3.1
7
+ before_install: gem install bundler
8
+ notifications:
9
+ email: false
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at d.zuev@rambler-co.ru. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rspec-testrail.gemspec
4
+ gemspec
5
+
6
+ gem 'rubocop'
7
+ gem 'awesome_print'
8
+ gem 'pry'
9
+ gem 'codeclimate-test-reporter', group: :test, require: nil
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Dmitry Zuev
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,73 @@
1
+ # RSpec::Testrail
2
+
3
+ [![Build Status](https://travis-ci.org/dmitryzuev/rspec-testrail.svg?branch=master)](https://travis-ci.org/dmitryzuev/rspec-testrail) [![Code Climate](https://codeclimate.com/github/dmitryzuev/rspec-testrail/badges/gpa.svg)](https://codeclimate.com/github/dmitryzuev/rspec-testrail) [![Test Coverage](https://codeclimate.com/github/dmitryzuev/rspec-testrail/badges/coverage.svg)](https://codeclimate.com/github/dmitryzuev/rspec-testrail/coverage)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'rspec-testrail'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install rspec-testrail
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ # spec/spec_helper
25
+
26
+ require 'rspec/testrail'
27
+
28
+ RSpec.configure do |config|
29
+
30
+ config.before :all do
31
+ # Uncomment if you are using gem `webmock`
32
+ # WebMock.allow_net_connect!
33
+ RSpec::Testrail.init url: 'http://testrail.site',
34
+ user: 'test@testrail.site',
35
+ password: ENV.fetch('TESTRAIL_PASSWORD', '12345678'),
36
+ project_id: 228,
37
+ suite_id: 1337,
38
+ run_name: `git rev-parse --abbrev-ref HEAD`.strip,
39
+ run_description: `git rev-parse HEAD`.strip
40
+ end
41
+
42
+ config.after :example, testrail_id: proc { |value| !value.nil? } do |example|
43
+ # Uncomment if you are using gem `webmock`
44
+ # WebMock.allow_net_connect!
45
+ RSpec::Testrail.process(example)
46
+ end
47
+ end
48
+ ```
49
+
50
+ ```ruby
51
+ # spec/models/user_spec.rb
52
+
53
+ RSpec.describe User, type: :model do
54
+ it 'is invalid without email', testrail_id: 31_337 do
55
+ # ...
56
+ end
57
+ end
58
+ ```
59
+
60
+ ## Development
61
+
62
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
63
+
64
+ 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).
65
+
66
+ ## Contributing
67
+
68
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dmitryzuev/rspec-testrail. 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.
69
+
70
+
71
+ ## License
72
+
73
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rspec/testrail"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,104 @@
1
+ #
2
+ # TestRail API binding for Ruby (API v2, available since TestRail 3.0)
3
+ #
4
+ # Learn more:
5
+ #
6
+ # http://docs.gurock.com/testrail-api2/start
7
+ # http://docs.gurock.com/testrail-api2/accessing
8
+ #
9
+ # Copyright Gurock Software GmbH. See license.md for details.
10
+ #
11
+
12
+ require 'net/http'
13
+ require 'net/https'
14
+ require 'uri'
15
+ require 'json'
16
+
17
+ module RSpec
18
+ module Testrail
19
+ class Client
20
+ @url = ''
21
+ @user = ''
22
+ @password = ''
23
+
24
+ attr_accessor :user
25
+ attr_accessor :password
26
+
27
+ def initialize(base_url, user, password)
28
+ base_url += '/' unless base_url =~ %r{/\/$/}
29
+ @url = base_url + 'index.php?/api/v2/'
30
+ @user = user
31
+ @password = password
32
+ end
33
+
34
+ #
35
+ # Send Get
36
+ #
37
+ # Issues a GET request (read) against the API and returns the result
38
+ # (as Ruby hash).
39
+ #
40
+ # Arguments:
41
+ #
42
+ # uri The API method to call including parameters
43
+ # (e.g. get_case/1)
44
+ #
45
+ def send_get(uri)
46
+ _send_request('GET', uri, nil)
47
+ end
48
+
49
+ #
50
+ # Send POST
51
+ #
52
+ # Issues a POST request (write) against the API and returns the result
53
+ # (as Ruby hash).
54
+ #
55
+ # Arguments:
56
+ #
57
+ # uri The API method to call including parameters
58
+ # (e.g. add_case/1)
59
+ # data The data to submit as part of the request (as
60
+ # Ruby hash, strings must be UTF-8 encoded)
61
+ #
62
+ def send_post(uri, data)
63
+ _send_request('POST', uri, data)
64
+ end
65
+
66
+ private
67
+
68
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
69
+ # rubocop:disable Metrics/PerceivedComplexity, Metrics/MethodLength
70
+ def _send_request(method, uri, data)
71
+ url = URI.parse(@url + uri)
72
+ if method == 'POST'
73
+ request = Net::HTTP::Post.new(url.path + '?' + url.query)
74
+ request.body = JSON.dump(data)
75
+ else
76
+ request = Net::HTTP::Get.new(url.path + '?' + url.query)
77
+ end
78
+ request.basic_auth(@user, @password)
79
+ request.add_field('Content-Type', 'application/json')
80
+
81
+ conn = Net::HTTP.new(url.host, url.port)
82
+ if url.scheme == 'https'
83
+ conn.use_ssl = true
84
+ conn.verify_mode = OpenSSL::SSL::VERIFY_NONE
85
+ end
86
+ response = conn.request(request)
87
+
88
+ result = (response.body && !response.body.empty?) ? JSON.parse(response.body) : {}
89
+
90
+ if response.code != '200'
91
+ error = (result && result.key?('error')) ? result['error'] : 'No additional error \
92
+ message received'
93
+
94
+ raise APIError, "TestRail API returned HTTP #{response.code} (#{error})"
95
+ end
96
+
97
+ result
98
+ end
99
+ end
100
+
101
+ class APIError < StandardError
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,5 @@
1
+ module RSpec
2
+ module Testrail
3
+ VERSION = '0.1.3'.freeze
4
+ end
5
+ end
@@ -0,0 +1,68 @@
1
+ require 'rspec/testrail/version'
2
+ require 'rspec/testrail/client'
3
+
4
+ module RSpec
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
+ run_name: hash[:run_name],
17
+ run_description: hash[:run_description]
18
+ }
19
+ end
20
+
21
+ def client
22
+ @client ||= Client.new(@options[:url], @options[:user], @options[:password])
23
+ end
24
+
25
+ def process(example)
26
+ if example.exception
27
+ status = 5
28
+ message = example.exception.message
29
+ else
30
+ status = 1
31
+ message = ''
32
+ end
33
+ client.send_post("add_result_for_case/#{testrun['id']}/#{example.metadata[:testrail_id]}",
34
+ status_id: status,
35
+ comment: message)
36
+ end
37
+
38
+ def reset
39
+ @options = nil
40
+ @client = nil
41
+ @testrun = nil
42
+ @testruns = nil
43
+ end
44
+
45
+ protected
46
+
47
+ def testrun
48
+ @testrun ||=
49
+ if testruns.empty?
50
+ client.send_post("add_run/#{@options[:project_id]}",
51
+ suite_id: @options[:suite_id],
52
+ name: @options[:run_name],
53
+ description: @options[:run_description])
54
+ else
55
+ client.send_post("update_run/#{testruns[0]['id']}",
56
+ description: @options[:run_description])
57
+ end
58
+ end
59
+
60
+ def testruns
61
+ @testruns ||= client.send_get("get_runs/#{@options[:project_id]}?#{URI.encode_www_form([["suite_id", @options[:suite_id]]])}")
62
+ .select do |run|
63
+ run['name'].include?(@options[:run_name])
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rspec/testrail/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'rspec-testrail-jamesdphillips'
8
+ spec.version = RSpec::Testrail::VERSION
9
+ spec.authors = ['James Phillips']
10
+ spec.email = ['jamesdphillips@gmail.com']
11
+
12
+ spec.summary = 'RSpec integration with TestRail'
13
+ spec.description = 'rspec-testrail help you update statuses in TestRail app'
14
+ spec.homepage = 'https://github.com/jamesdphillips/rspec-testrail'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ .reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = 'exe'
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.10'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'webmock', '~> 2.1'
26
+
27
+ spec.add_runtime_dependency 'rspec', '~> 3.0'
28
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-testrail-jamesdphillips
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - James Phillips
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-10-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
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'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: rspec-testrail help you update statuses in TestRail app
70
+ email:
71
+ - jamesdphillips@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".rubocop.yml"
79
+ - ".ruby-version"
80
+ - ".travis.yml"
81
+ - CODE_OF_CONDUCT.md
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/setup
88
+ - lib/rspec/testrail.rb
89
+ - lib/rspec/testrail/client.rb
90
+ - lib/rspec/testrail/version.rb
91
+ - rspec-testrail.gemspec
92
+ homepage: https://github.com/jamesdphillips/rspec-testrail
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubygems_version: 3.0.3
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: RSpec integration with TestRail
115
+ test_files: []