testrail 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --profile
3
+ --drb
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.2"
4
+ - "1.9.3"
5
+ - rbx-19mode
6
+ # uncomment this line if your project needs to run something other than `rake`:
7
+ # script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ gem "httparty"
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", "~> 2.8.0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "~> 1.1.3"
12
+ gem "jeweler", "~> 1.8.4"
13
+ gem "webmock", "~> 1.9.0"
14
+ gem "simplecov", ">= 0"
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,48 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.2)
5
+ crack (0.3.1)
6
+ diff-lcs (1.1.3)
7
+ git (1.2.5)
8
+ httparty (0.9.0)
9
+ multi_json (~> 1.0)
10
+ multi_xml
11
+ jeweler (1.8.4)
12
+ bundler (~> 1.0)
13
+ git (>= 1.2.5)
14
+ rake
15
+ rdoc
16
+ json (1.7.5)
17
+ multi_json (1.3.7)
18
+ multi_xml (0.5.1)
19
+ rake (10.0.2)
20
+ rdoc (3.12)
21
+ json (~> 1.4)
22
+ rspec (2.8.0)
23
+ rspec-core (~> 2.8.0)
24
+ rspec-expectations (~> 2.8.0)
25
+ rspec-mocks (~> 2.8.0)
26
+ rspec-core (2.8.0)
27
+ rspec-expectations (2.8.0)
28
+ diff-lcs (~> 1.1.2)
29
+ rspec-mocks (2.8.0)
30
+ simplecov (0.7.1)
31
+ multi_json (~> 1.0)
32
+ simplecov-html (~> 0.7.1)
33
+ simplecov-html (0.7.1)
34
+ webmock (1.9.0)
35
+ addressable (>= 2.2.7)
36
+ crack (>= 0.1.7)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ bundler (~> 1.1.3)
43
+ httparty
44
+ jeweler (~> 1.8.4)
45
+ rdoc (~> 3.12)
46
+ rspec (~> 2.8.0)
47
+ simplecov
48
+ webmock (~> 1.9.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Kristine Robison
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # testrail [![Travis Status](https://travis-ci.org/kris-at-tout/testrail.png)](https://travis-ci.org/kris-at-tout/testrail)
2
+
3
+ A Ruby client that tries to match TestRail's API one-to-one, while still
4
+ providing an idiomatic interface.
5
+
6
+ ## Installation
7
+ gem install testrail
8
+
9
+ ## Configuration
10
+
11
+ By default, Testrail's configuration points to their hosted service. You can set your api_key in either of the following ways:
12
+
13
+ Testrail.config.api_key = 'my_api_key'
14
+
15
+ Testrail.configure do |c|
16
+ c.api_key = 'my_api_key'
17
+ end
18
+
19
+ Configuration options [defaults] include:
20
+ * server: the location of the TestRail application. ['https://example.testrail.com']
21
+ * api_path: the path on the server that provides the api. ['/index.php?/miniapi/']
22
+ * api_key: the api_key required to access the TestRail application. [nil]
23
+ * logger: the logging instance to use for capturing log messages. [Logger.new]
24
+
25
+ ## Usage
26
+
27
+ client = Testrail::Client.new
28
+ response = client.add_case(<section_id>, body: {
29
+ title: "A New Test",
30
+ priority_id: 4,
31
+ references: 'url_to_issue_tracker'
32
+ })
33
+
34
+ test_id = response.payload if response.success
35
+ error = response.error unless response.success
36
+
37
+ # ToDo
38
+
39
+ * Add Testrail specific objects to represent the Testrail domain.
40
+
41
+ # Contributing to testrail
42
+
43
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
44
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
45
+ * Fork the project.
46
+ * Start a feature/bugfix branch.
47
+ * Commit and push until you are happy with your contribution.
48
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
49
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
50
+
51
+ ## Copyright
52
+
53
+ Copyright (c) 2012 Kristine Robison. See LICENSE.txt for
54
+ further details.
55
+
data/Rakefile ADDED
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ require_relative './lib/testrail/version'
16
+ Jeweler::Tasks.new do |gem|
17
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
18
+ gem.name = "testrail"
19
+ gem.version = Testrail::VERSION
20
+ gem.homepage = "http://github.com/kris-at-tout/testrail"
21
+ gem.license = "MIT"
22
+ gem.summary = "A Ruby client library for TestRail"
23
+ gem.description = <<-EOS
24
+ A Ruby client that tries to match TestRail's API one-to-one, while still
25
+ providing an idiomatic interface.
26
+ EOS
27
+ gem.email = "krobison@gmail.com"
28
+ gem.authors = ["Kristine Robison"]
29
+ # dependencies defined in Gemfile
30
+ end
31
+ Jeweler::RubygemsDotOrgTasks.new
32
+
33
+ require 'rspec/core'
34
+ require 'rspec/core/rake_task'
35
+ RSpec::Core::RakeTask.new(:spec) do |spec|
36
+ spec.pattern = FileList['spec/**/*_spec.rb']
37
+ end
38
+
39
+ RSpec::Core::RakeTask.new(:simplecov) do |spec|
40
+ spec.pattern = 'spec/**/*_spec.rb'
41
+ spec.rcov = true
42
+ end
43
+
44
+ task :default => :spec
45
+
46
+ require 'rdoc/task'
47
+ Rake::RDocTask.new do |rdoc|
48
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
+
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "testrail #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('lib/**/*.rb')
54
+ end
data/lib/testrail.rb ADDED
@@ -0,0 +1,9 @@
1
+ Dir[File.join(File.dirname(__FILE__), 'testrail', '*.rb')].each do |f|
2
+ require f
3
+ end
4
+
5
+ module Testrail
6
+ def self.logger
7
+ Testrail.config.logger
8
+ end
9
+ end
@@ -0,0 +1,169 @@
1
+ module Testrail
2
+ class Client
3
+
4
+ attr_reader :request
5
+
6
+ def initialize
7
+ @request = Testrail::Request
8
+ end
9
+
10
+ # Test Results - see http://docs.gurock.com/testrail-api/reference-results
11
+ def add_result(test_id, opts = {})
12
+ request.post('add_result', test_id, opts)
13
+ end
14
+
15
+ def add_result_for_case(run_id, case_id, opts = {})
16
+ request.post('add_result_for_case', run_id, case_id, opts)
17
+ end
18
+
19
+ # Test - see http://docs.gurock.com/testrail-api/reference-tests
20
+ def get_test(test_id, opts = {})
21
+ request.get('get_test', test_id, opts)
22
+ end
23
+
24
+ def get_tests(run_id, opts = {})
25
+ request.get('get_tests', run_id, opts)
26
+ end
27
+
28
+ # Test Cases - see http://docs.gurock.com/testrail-api/reference-cases
29
+ def get_case(case_id, opts = {})
30
+ request.get('get_case', case_id, opts)
31
+ end
32
+
33
+ def get_cases(suite_id, section_id, opts = {})
34
+ request.get('get_cases', [suite_id, section_id], opts)
35
+ end
36
+
37
+ def add_case(section_id, opts = {})
38
+ request.post('add_case', section_id, opts)
39
+ end
40
+
41
+ def update_case(case_id, opts = {})
42
+ request.post('update_case', case_id, opts)
43
+ end
44
+
45
+ def delete_case(case_id, opts = {})
46
+ request.post('delete_case', case_id, opts)
47
+ end
48
+
49
+ # Suites and Sections - see http://docs.gurock.com/testrail-api/reference-suites
50
+ def get_suite(suite_id, opts = {})
51
+ request.get('get_suite', suite_id, opts)
52
+ end
53
+
54
+ def get_suites(project_id, opts = {})
55
+ request.get('get_suites', project_id, opts)
56
+ end
57
+
58
+ def get_section(section_id, opts = {})
59
+ request.get('get_section', section_id, opts)
60
+ end
61
+
62
+ def get_sections(suite_id, opts = {})
63
+ request.get('get_sections', suite_id, opts)
64
+ end
65
+
66
+ def add_suite(project_id, opts = {})
67
+ request.post('add_suite', project_id, opts)
68
+ end
69
+
70
+ def add_section(suite_id, opts = {})
71
+ request.post('add_section', suite_id, opts)
72
+ end
73
+
74
+ # Test Runs - see http://docs.gurock.com/testrail-api/reference-runs
75
+ def get_run(run_id, opts = {})
76
+ request.get('get_run', run_id, opts)
77
+ end
78
+
79
+ def get_runs(project_id, plan_id, opts = {})
80
+ request.get('get_runs', project_id, plan_id, opts)
81
+ end
82
+
83
+ def add_run(suite_id, opts = {})
84
+ request.post('add_run', suite_id, opts)
85
+ end
86
+
87
+ def close_run(run_id, opts = {})
88
+ request.post('close_run', run_id, opts)
89
+ end
90
+
91
+ # Test Plans - see http://docs.gurock.com/testrail-api/reference-plans
92
+ def get_plan(plan_id, opts = {})
93
+ request.get('get_plan', plan_id, opts)
94
+ end
95
+
96
+ def get_plans(project_id, opts = {})
97
+ request.get('get_plans', project_id, opts)
98
+ end
99
+
100
+ def add_plan(project_id, opts = {})
101
+ request.post('add_plan', project_id, opts)
102
+ end
103
+
104
+ def add_plan_entries(plan_id, opts = {})
105
+ request.post('add_plan_entries', plan_id, opts)
106
+ end
107
+
108
+ def close_plan(plan_id, opts = {})
109
+ request.post('close_plan', plan_id, opts)
110
+ end
111
+
112
+ # Milestones - see http://docs.gurock.com/testrail-api/reference-milestones
113
+ def get_milestone(milestone_id, opts = {})
114
+ request.get('get_milestone', milestone_id, opts)
115
+ end
116
+
117
+ def get_milestones(project_id, opts = {})
118
+ request.get('get_milestones', project_id, opts)
119
+ end
120
+
121
+ def add_milestone(project_id, opts = {})
122
+ request.post('add_milestone', project_id, opts)
123
+ end
124
+
125
+ # Projects - see http://docs.gurock.com/testrail-api/reference-projects
126
+ def get_project(project_id, opts = {})
127
+ request.get('get_project', project_id, opts)
128
+ end
129
+
130
+ def get_projects(opts = {})
131
+ request.get('get_projects', opts)
132
+ end
133
+
134
+
135
+ # COMMANDS.each do |method_name|
136
+ # define_method method_name
137
+ # end
138
+
139
+ COMMANDS = %w[add_result
140
+ add_result_for_case
141
+ get_test
142
+ get_tests
143
+ get_case
144
+ get_cases
145
+ add_case
146
+ update_case
147
+ delete_case
148
+ get_suite
149
+ get_suites
150
+ get_section
151
+ get_sections
152
+ add_suite
153
+ add_section
154
+ get_run
155
+ get_runs
156
+ add_run
157
+ close_run
158
+ get_plan
159
+ get_plans
160
+ add_plan
161
+ add_plan_entries
162
+ close_plan
163
+ get_milestone
164
+ get_milestones
165
+ add_milestone
166
+ get_project
167
+ get_projects]
168
+ end
169
+ end
@@ -0,0 +1,17 @@
1
+ module Testrail
2
+ module CommandHelper
3
+ def build_command(command, ids = nil)
4
+ command = Testrail.config.server + Testrail.config.api_path + command
5
+ unless ids.nil?
6
+ ids = '/' + [ids].flatten.join('/')
7
+ command += ids
8
+ end
9
+ command + key
10
+ end
11
+
12
+ private
13
+ def key
14
+ '&key=' + String(Testrail.config.api_key)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,31 @@
1
+ require 'logger'
2
+
3
+ module Testrail
4
+
5
+ def self.configure(&block)
6
+ @config = Config.new &block
7
+ end
8
+
9
+ def self.config
10
+ @config ||= Config.new
11
+ end
12
+
13
+ class Config
14
+ attr_accessor :headers, :server, :api_path, :api_key, :logger
15
+
16
+ def initialize(&block)
17
+ default_config
18
+ instance_eval(&block) if block_given?
19
+ end
20
+
21
+ def default_config
22
+ @headers = {
23
+ "Accept" => "application/json"
24
+ }
25
+ @server = "https://example.testrail.com"
26
+ @api_path = "/index.php?/miniapi/"
27
+ @api_key = nil
28
+ @logger = Logger.new STDOUT
29
+ end
30
+ end
31
+ end