easyqa_api 0.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 40d475fc995b73f6efffc0a06703c5778a9a7b30
4
+ data.tar.gz: e010dff133304a8c252dd2566e591f83f60cfe73
5
+ SHA512:
6
+ metadata.gz: 96530f808571c49685b0ef76806b3a37b319ea41279f899549cd2419df9c888ea5d3e924dfdfacfd4d2caac698a99fd4735439765c7558c1ea99e85b9bd250b7
7
+ data.tar.gz: 94ab8c7dcf4c8eb68771e187dfa65849fb23c0a214365a85efcbde15067868438c18610705023bb6d3e7ff817ae60b72592478245ece14c55512d408acc17a4c
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.rubocop.yml
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.13.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at gashuk95@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in easyqa_api.gemspec
4
+ gemspec
5
+
6
+ gem 'pry'
@@ -0,0 +1,36 @@
1
+ # EasyqaApi
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/easyqa_api`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'easyqa_api'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install easyqa_api
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/easyqa_api. 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.
36
+
@@ -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
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'pry'
5
+ require 'easyqa_api'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ Pry.start
@@ -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,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'easyqa_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'easyqa_api'
8
+ spec.version = EasyqaApi::VERSION
9
+ spec.authors = ['Thinkmobiles']
10
+ spec.email = ['gashuk95@gmail.com']
11
+
12
+ spec.summary = %q(API to EasyQA)
13
+ spec.description = %q(Simple gem for EasyQA API)
14
+ spec.homepage = 'https://app.geteasyqa.com/'
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against " \
22
+ "public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = 'exe'
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ['lib']
31
+
32
+ spec.add_development_dependency 'bundler', '~> 1.13'
33
+ spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'rspec', '~> 3.0'
35
+ spec.add_dependency 'faraday', '~> 0.9.2'
36
+ spec.add_dependency 'faraday_middleware', '~> 0.10.0'
37
+ spec.add_dependency 'activesupport', '~> 5.0', '> 4.0'
38
+ end
@@ -0,0 +1,19 @@
1
+ require 'active_support'
2
+ require 'easyqa_api/helpers/easyqa_api_helper'
3
+ require 'easyqa_api/version'
4
+ require 'easyqa_api/configuration'
5
+ require 'easyqa_api/exceptions'
6
+ require 'easyqa_api/item'
7
+ require 'easyqa_api/items/user'
8
+ require 'easyqa_api/items/organization'
9
+ require 'easyqa_api/items/project'
10
+ require 'easyqa_api/items/role'
11
+ require 'easyqa_api/items/status'
12
+ require 'easyqa_api/items/test_plan'
13
+ require 'easyqa_api/items/test_module'
14
+ require 'easyqa_api/items/test_case'
15
+ require 'easyqa_api/items/test_run'
16
+ require 'easyqa_api/items/test_run_result'
17
+ require 'easyqa_api/items/test_object'
18
+ require 'easyqa_api/items/issue'
19
+ require 'easyqa_api/items/issue_attachment'
@@ -0,0 +1,24 @@
1
+ module EasyqaApi
2
+ class Configuration
3
+ class << self
4
+ attr_accessor :url, :api_version
5
+
6
+ def api_path
7
+ "/api/v#{@api_version}/"
8
+ end
9
+ end
10
+
11
+ @url = 'http://localhost:3000/'
12
+ @api_version = 1
13
+ end
14
+
15
+ class << self
16
+ attr_accessor :configuration
17
+ end
18
+
19
+ @configuration = Configuration
20
+
21
+ def self.setup
22
+ yield @configuration
23
+ end
24
+ end
@@ -0,0 +1,33 @@
1
+ module EasyqaApi
2
+ class NotFoundError < StandardError
3
+ end
4
+
5
+ class PermissionError < StandardError
6
+ end
7
+
8
+ class RequestError < StandardError
9
+ end
10
+
11
+ class ValidationError < StandardError
12
+ end
13
+
14
+ class Exception
15
+ EXCEPTIONS = {
16
+ 404 => EasyqaApi::NotFoundError,
17
+ 403 => EasyqaApi::PermissionError,
18
+ 400 => EasyqaApi::RequestError,
19
+ 422 => EasyqaApi::ValidationError
20
+ }.freeze
21
+
22
+ def self.check_response_status!(response)
23
+ raise EXCEPTIONS[response.status], response.body['message'] || retrieve_mess(response.body) \
24
+ if EXCEPTIONS[response.status]
25
+ end
26
+
27
+ def self.retrieve_mess(response_boddy)
28
+ response_boddy.each_with_object('') do |(key, values), result_message|
29
+ result_message << "#{key}: #{values.join('; ')}\n"
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,25 @@
1
+ module EasyqaApi
2
+ module ClassMethodsSettable
3
+ METHODS = [:create, :show, :update, :delete].freeze
4
+
5
+ def install_class_methods!(options = {})
6
+ METHODS.each do |method_name|
7
+ define_singleton_method method_name do |*attrs|
8
+ instance = new
9
+ instance.install_variables!(
10
+ instance.send(method_name, *attrs).merge(attrs.find { |attr| attr.is_a? Hash } || {})
11
+ )
12
+ instance
13
+ end if method_permitted?(options, method_name)
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def method_permitted?(options, method_name)
20
+ (options[:only].nil? && options[:except].nil?) || \
21
+ (options[:only] && options[:only].include?(method_name)) || \
22
+ (options[:except] && !options[:except].include?(method_name))
23
+ end
24
+ end
25
+ end
@@ -0,0 +1 @@
1
+ require_relative 'class_methods_settable'
@@ -0,0 +1,74 @@
1
+ require 'faraday_middleware'
2
+
3
+ module EasyqaApi
4
+ class Item
5
+ extend ClassMethodsSettable
6
+
7
+ CONNECTION = {
8
+ json: {
9
+ instance: -> { json_connection },
10
+ content_type: 'application/json'
11
+ },
12
+ multipart: {
13
+ instance: -> { multipart_connection },
14
+ content_type: 'multipart/form-data'
15
+ }
16
+ }.freeze
17
+
18
+ class << self
19
+ def json_connection
20
+ @json_connection ||= Faraday.new(url: EasyqaApi.configuration.url) do |faraday|
21
+ faraday.request :json
22
+ faraday.response :json
23
+ faraday.adapter Faraday.default_adapter
24
+ end
25
+ end
26
+
27
+ def multipart_connection
28
+ @multipart_connection ||= Faraday.new(url: EasyqaApi.configuration.url) do |faraday|
29
+ faraday.request :multipart
30
+ faraday.response :json
31
+ faraday.adapter Faraday.default_adapter
32
+ end
33
+ end
34
+
35
+ def send_request(url, html_method, type = :json, &block)
36
+ response = EasyqaApi::Item::CONNECTION[type][:instance].call.send(html_method) do |req|
37
+ req.url EasyqaApi.configuration.api_path + url
38
+ req.headers['Content-Type'] = EasyqaApi::Item::CONNECTION[type][:content_type]
39
+ yield(req) if block
40
+ end
41
+
42
+ operation_status(response)
43
+ end
44
+
45
+ def operation_status(response)
46
+ EasyqaApi::Exception.check_response_status!(response)
47
+ response.body
48
+ end
49
+ end
50
+
51
+ def initialize(*_args)
52
+ end
53
+
54
+ @@default_user = nil
55
+
56
+ def install_variables!(arguments)
57
+ allowed_methods = retrive_allowed_methods
58
+ arguments.each do |key, value|
59
+ method_name = "#{key}=".to_sym
60
+ send(method_name, value) if allowed_methods.include? method_name
61
+ end
62
+ end
63
+
64
+ private
65
+
66
+ def send_request(*attrs, &block)
67
+ self.class.send_request(*attrs, &block)
68
+ end
69
+
70
+ def retrive_allowed_methods
71
+ public_methods.select { |method_name| method_name =~ /[a-z]=$/ }
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,59 @@
1
+ module EasyqaApi
2
+ class Issue < Item
3
+ attr_accessor :id, :attributes, :project_token
4
+
5
+ install_class_methods!
6
+
7
+ def self.all(project_token, user = @@default_user)
8
+ send_request('issues', :get) do |req|
9
+ req.params = {
10
+ auth_token: user.auth_token,
11
+ token: project_token
12
+ }
13
+ end
14
+ end
15
+
16
+ def create(attrs, user = @@default_user)
17
+ attrs = { project_token: @project_token }.merge(attrs)
18
+ @attributes = send_request('projects/issues/create', :post, :multipart) do |req|
19
+ req.body = {
20
+ token: attrs[:project_token],
21
+ auth_token: user.auth_token,
22
+ }.merge(attrs.except(:project_token))
23
+ end
24
+ end
25
+
26
+ def show(attrs = {}, user = @@default_user)
27
+ attrs = { id: @id, project_token: @project_token }.merge(attrs)
28
+ attrs[:id] = "pid#{attrs.delete(:id_in_project)}" if attrs[:id_in_project]
29
+ @attributes = send_request("issues/#{id}", :get) do |req|
30
+ req.params = {
31
+ token: attrs[:project_token],
32
+ auth_token: user.auth_token
33
+ }
34
+ end
35
+ end
36
+
37
+ def update(attrs, user = @@default_user)
38
+ attrs = { id: @id, project_token: @project_token }.merge(attrs)
39
+ attrs[:id] = "pid#{attrs.delete(:id_in_project)}" if attrs[:id_in_project]
40
+ @attributes = send_request("issues/#{attrs[:id]}", :put) do |req|
41
+ req.body = {
42
+ token: attrs[:project_token],
43
+ auth_token: user.auth_token
44
+ }.merge(attrs.except(:project_token))
45
+ end
46
+ end
47
+
48
+ def delete(attrs = {}, user = @@default_user)
49
+ attrs = { id: @id, project_token: @project_token }.merge(attrs)
50
+ attrs[:id] = "pid#{attrs.delete(:id_in_project)}" if attrs[:id_in_project]
51
+ @attributes = send_request("issues/#{attrs[:id]}", :delete) do |req|
52
+ req.params = {
53
+ token: attrs[:project_token],
54
+ auth_token: user.auth_token
55
+ }
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,28 @@
1
+ module EasyqaApi
2
+ class IssueAttachment < Item
3
+ attr_accessor :id, :attributes, :project_token, :issue_id
4
+
5
+ install_class_methods! only: [:create, :delete]
6
+
7
+ def create(attrs, user = @@default_user)
8
+ attrs = { project_token: @project_token, issue_id: @issue_id }.merge(attrs)
9
+ attrs[:issue_id] = "pid#{attrs.delete(:issue_id_in_project)}" if attrs[:issue_id_in_project]
10
+ @attributes = send_request("issues/#{attrs[:issue_id]}/attachments", :post, :multipart) do |req|
11
+ req.body = {
12
+ token: attrs[:project_token],
13
+ auth_token: user.auth_token
14
+ }.merge(attrs.except(:project_token))
15
+ end
16
+ end
17
+
18
+ def delete(attrs = {}, user = @@default_user)
19
+ attrs = { id: @id, project_token: @project_token }.merge(attrs)
20
+ @attributes = send_request("attachments/#{attrs[:id]}", :delete) do |req|
21
+ req.params = {
22
+ token: attrs[:project_token],
23
+ auth_token: user.auth_token
24
+ }
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,50 @@
1
+ module EasyqaApi
2
+ class Organization < Item
3
+ attr_accessor :title, :description, :id, :attributes
4
+
5
+ install_class_methods!
6
+
7
+ def self.all(user = @@default_user)
8
+ send_request('organizations', :get) do |req|
9
+ req.params = {
10
+ auth_token: user.auth_token
11
+ }
12
+ end
13
+ end
14
+
15
+ def create(attrs, user = @@default_user)
16
+ @attributes = send_request('organizations', :post) do |req|
17
+ req.body = {
18
+ organization: attrs,
19
+ auth_token: user.auth_token
20
+ }
21
+ end
22
+ end
23
+
24
+ def show(id = @id, user = @@default_user)
25
+ @attributes = send_request("organizations/#{id}", :get) do |req|
26
+ req.params = {
27
+ auth_token: user.auth_token
28
+ }
29
+ end
30
+ end
31
+
32
+ def update(attrs, user = @@default_user)
33
+ attrs = { id: @id }.merge(attrs)
34
+ @attributes = send_request("organizations/#{attrs[:id]}", :put) do |req|
35
+ req.body = {
36
+ organization: attrs.except(:id),
37
+ auth_token: user.auth_token
38
+ }
39
+ end
40
+ end
41
+
42
+ def delete(id = @id, user = @@default_user)
43
+ @attributes = send_request("organizations/#{id}", :delete) do |req|
44
+ req.params = {
45
+ auth_token: user.auth_token
46
+ }
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,51 @@
1
+ module EasyqaApi
2
+ class Project < Item
3
+ attr_accessor :title, :id, :attributes
4
+
5
+ install_class_methods!
6
+
7
+ def self.all(user = @@default_user)
8
+ send_request('projects', :get) do |req|
9
+ req.params = {
10
+ auth_token: user.auth_token
11
+ }
12
+ end
13
+ end
14
+
15
+ def create(attrs, user = @@default_user)
16
+ @attributes = send_request('projects', :post) do |req|
17
+ req.body = {
18
+ organization_id: attrs[:organization_id],
19
+ project: attrs.except(:organization_id),
20
+ auth_token: user.auth_token
21
+ }
22
+ end
23
+ end
24
+
25
+ def show(id = @id, user = @@default_user)
26
+ @attributes = send_request("projects/#{id}", :get) do |req|
27
+ req.params = {
28
+ auth_token: user.auth_token
29
+ }
30
+ end
31
+ end
32
+
33
+ def update(attrs, user = @@default_user)
34
+ attrs = { id: @id }.merge(attrs)
35
+ @attributes = send_request("projects/#{attrs[:id]}", :put) do |req|
36
+ req.body = {
37
+ project: attrs.except(:id),
38
+ auth_token: user.auth_token
39
+ }
40
+ end
41
+ end
42
+
43
+ def delete(id = @id, user = @@default_user)
44
+ @attributes = send_request("projects/#{id}", :delete) do |req|
45
+ req.params = {
46
+ auth_token: user.auth_token
47
+ }
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,48 @@
1
+ module EasyqaApi
2
+ class Role < Item
3
+ attr_accessor :role, :id, :attributes
4
+
5
+ install_class_methods!
6
+
7
+ def self.all(organization_id, user = @@default_user)
8
+ send_request("organizations/#{organization_id}/roles", :get) do |req|
9
+ req.params = {
10
+ auth_token: user.auth_token
11
+ }
12
+ end
13
+ end
14
+
15
+ def create(attrs, user = @@default_user)
16
+ @attributes = send_request("organizations/#{attrs[:organization_id]}/roles", :post) do |req|
17
+ req.body = {
18
+ auth_token: user.auth_token
19
+ }.merge(attrs.except(:organization_id))
20
+ end
21
+ end
22
+
23
+ def show(id = @id, user = @@default_user)
24
+ @attributes = send_request("roles/#{id}", :get) do |req|
25
+ req.params = {
26
+ auth_token: user.auth_token
27
+ }
28
+ end
29
+ end
30
+
31
+ def update(role, id = @id, user = @@default_user)
32
+ @attributes = send_request("roles/#{id}", :put) do |req|
33
+ req.body = {
34
+ role: role,
35
+ auth_token: user.auth_token
36
+ }
37
+ end
38
+ end
39
+
40
+ def delete(id = @id, user = @@default_user)
41
+ @attributes = send_request("roles/#{id}", :delete) do |req|
42
+ req.params = {
43
+ auth_token: user.auth_token
44
+ }
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,56 @@
1
+ module EasyqaApi
2
+ class Status < Item
3
+ attr_accessor :name, :id, :attributes, :project_token
4
+
5
+ install_class_methods!
6
+
7
+ def self.all(project_token, user = @@default_user)
8
+ send_request('statuses', :get) do |req|
9
+ req.params = {
10
+ auth_token: user.auth_token,
11
+ token: project_token
12
+ }
13
+ end
14
+ end
15
+
16
+ def create(attrs, user = @@default_user)
17
+ attrs = { project_token: @project_token }.merge(attrs)
18
+ @attributes = send_request('statuses', :post) do |req|
19
+ req.body = {
20
+ status_object: attrs.slice(:name),
21
+ token: attrs[:project_token],
22
+ auth_token: user.auth_token
23
+ }
24
+ end
25
+ end
26
+
27
+ def show(project_token = @project_token, id = @id, user = @@default_user)
28
+ @attributes = send_request("statuses/#{id}", :get) do |req|
29
+ req.params = {
30
+ token: project_token,
31
+ auth_token: user.auth_token
32
+ }
33
+ end
34
+ end
35
+
36
+ def update(attrs, user = @@default_user)
37
+ attrs = { id: @id, project_token: @project_token }.merge(attrs)
38
+ @attributes = send_request("statuses/#{attrs[:id]}", :put) do |req|
39
+ req.body = {
40
+ status_object: attrs.slice(:name),
41
+ token: attrs[:project_token],
42
+ auth_token: user.auth_token
43
+ }
44
+ end
45
+ end
46
+
47
+ def delete(project_token = @project_token, id = @id, user = @@default_user)
48
+ @attributes = send_request("statuses/#{id}", :delete) do |req|
49
+ req.params = {
50
+ token: project_token,
51
+ auth_token: user.auth_token
52
+ }
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,56 @@
1
+ module EasyqaApi
2
+ class TestCase < Item
3
+ attr_accessor :title, :id, :attributes, :project_token, :module_id
4
+
5
+ install_class_methods!
6
+
7
+ def self.all(attrs, user = @@default_user)
8
+ send_request("#{attrs[:parent_name]}/#{attrs[:parent_id]}/test_cases", :get) do |req|
9
+ req.params = {
10
+ auth_token: user.auth_token,
11
+ token: attrs[:project_token]
12
+ }
13
+ end
14
+ end
15
+
16
+ def create(attrs, user = @@default_user)
17
+ attrs = { project_token: @project_token, module_id: @module_id }.merge(attrs)
18
+ @attributes = send_request("test_modules/#{attrs[:module_id]}/test_cases", :post) do |req|
19
+ req.body = {
20
+ test_case: attrs.except(:project_token, :module_id),
21
+ token: attrs[:project_token],
22
+ auth_token: user.auth_token
23
+ }
24
+ end
25
+ end
26
+
27
+ def show(project_token = @project_token, id = @id, user = @@default_user)
28
+ @attributes = send_request("test_cases/#{id}", :get) do |req|
29
+ req.params = {
30
+ token: project_token,
31
+ auth_token: user.auth_token
32
+ }
33
+ end
34
+ end
35
+
36
+ def update(attrs, user = @@default_user)
37
+ attrs = { id: @id, project_token: @project_token }.merge(attrs)
38
+ @attributes = send_request("test_cases/#{attrs[:id]}", :put) do |req|
39
+ req.body = {
40
+ test_case: attrs.except(:project_token, :id),
41
+ token: attrs[:project_token],
42
+ auth_token: user.auth_token
43
+ }
44
+ end
45
+ end
46
+
47
+ def delete(project_token = @project_token, id = @id, user = @@default_user)
48
+ @attributes = send_request("test_cases/#{id}", :delete) do |req|
49
+ req.params = {
50
+ token: project_token,
51
+ auth_token: user.auth_token
52
+ }
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,56 @@
1
+ module EasyqaApi
2
+ class TestModule < Item
3
+ attr_accessor :title, :id, :attributes, :project_token, :test_plan_id
4
+
5
+ install_class_methods!
6
+
7
+ def self.all(project_token, test_plan_id, user = @@default_user)
8
+ send_request("test_plans/#{test_plan_id}/test_modules", :get) do |req|
9
+ req.params = {
10
+ auth_token: user.auth_token,
11
+ token: project_token
12
+ }
13
+ end
14
+ end
15
+
16
+ def create(attrs, user = @@default_user)
17
+ attrs = { project_token: @project_token, test_plan_id: @test_plan_id }.merge(attrs)
18
+ @attributes = send_request("test_plans/#{attrs[:test_plan_id]}/test_modules", :post) do |req|
19
+ req.body = {
20
+ test_module: attrs.except(:project_token, :test_plan_id),
21
+ token: attrs[:project_token],
22
+ auth_token: user.auth_token
23
+ }
24
+ end
25
+ end
26
+
27
+ def show(project_token = @project_token, id = @id, user = @@default_user)
28
+ @attributes = send_request("test_modules/#{id}", :get) do |req|
29
+ req.params = {
30
+ token: project_token,
31
+ auth_token: user.auth_token
32
+ }
33
+ end
34
+ end
35
+
36
+ def update(attrs, user = @@default_user)
37
+ attrs = { id: @id, project_token: @project_token }.merge(attrs)
38
+ @attributes = send_request("test_modules/#{attrs[:id]}", :put) do |req|
39
+ req.body = {
40
+ test_module: attrs.except(:project_token),
41
+ token: attrs[:project_token],
42
+ auth_token: user.auth_token
43
+ }
44
+ end
45
+ end
46
+
47
+ def delete(project_token = @project_token, id = @id, user = @@default_user)
48
+ @attributes = send_request("test_modules/#{id}", :delete) do |req|
49
+ req.params = {
50
+ token: project_token,
51
+ auth_token: user.auth_token
52
+ }
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,44 @@
1
+ module EasyqaApi
2
+ class TestObject < Item
3
+ attr_accessor :id, :attributes, :project_token
4
+
5
+ install_class_methods! except: [:update]
6
+
7
+ def self.all(project_token, user = @@default_user)
8
+ send_request('test_objects', :get) do |req|
9
+ req.params = {
10
+ auth_token: user.auth_token,
11
+ token: project_token
12
+ }
13
+ end
14
+ end
15
+
16
+ def create(attrs, user = @@default_user)
17
+ attrs = { project_token: @project_token }.merge(attrs)
18
+ @attributes = send_request('test_objects', :post, :multipart) do |req|
19
+ req.body = {
20
+ token: attrs[:project_token],
21
+ auth_token: user.auth_token
22
+ }.merge(attrs.except(:project_token))
23
+ end
24
+ end
25
+
26
+ def show(project_token = @project_token, id = @id, user = @@default_user)
27
+ @attributes = send_request("test_objects/#{id}", :get) do |req|
28
+ req.params = {
29
+ token: project_token,
30
+ auth_token: user.auth_token
31
+ }
32
+ end
33
+ end
34
+
35
+ def delete(project_token = @project_token, id = @id, user = @@default_user)
36
+ @attributes = send_request("test_objects/#{id}", :delete) do |req|
37
+ req.params = {
38
+ token: project_token,
39
+ auth_token: user.auth_token
40
+ }
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,56 @@
1
+ module EasyqaApi
2
+ class TestPlan < Item
3
+ attr_accessor :title, :id, :attributes, :project_token
4
+
5
+ install_class_methods!
6
+
7
+ def self.all(project_token, user = @@default_user)
8
+ send_request('test_plans', :get) do |req|
9
+ req.params = {
10
+ auth_token: user.auth_token,
11
+ token: project_token
12
+ }
13
+ end
14
+ end
15
+
16
+ def create(attrs, user = @@default_user)
17
+ attrs = { project_token: @project_token }.merge(attrs)
18
+ @attributes = send_request('test_plans', :post) do |req|
19
+ req.body = {
20
+ test_plan: attrs.except(:project_token),
21
+ token: attrs[:project_token],
22
+ auth_token: user.auth_token
23
+ }
24
+ end
25
+ end
26
+
27
+ def show(project_token = @project_token, id = @id, user = @@default_user)
28
+ @attributes = send_request("test_plans/#{id}", :get) do |req|
29
+ req.params = {
30
+ token: project_token,
31
+ auth_token: user.auth_token
32
+ }
33
+ end
34
+ end
35
+
36
+ def update(attrs, user = @@default_user)
37
+ attrs = { id: @id, project_token: @project_token }.merge(attrs)
38
+ @attributes = send_request("test_plans/#{attrs[:id]}", :put) do |req|
39
+ req.body = {
40
+ test_plan: attrs.except(:project_token),
41
+ token: attrs[:project_token],
42
+ auth_token: user.auth_token
43
+ }
44
+ end
45
+ end
46
+
47
+ def delete(project_token = @project_token, id = @id, user = @@default_user)
48
+ @attributes = send_request("test_plans/#{id}", :delete) do |req|
49
+ req.params = {
50
+ token: project_token,
51
+ auth_token: user.auth_token
52
+ }
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,56 @@
1
+ module EasyqaApi
2
+ class TestRun < Item
3
+ attr_accessor :title, :id, :attributes, :project_token
4
+
5
+ install_class_methods!
6
+
7
+ def self.all(project_token, user = @@default_user)
8
+ send_request('test_runs', :get) do |req|
9
+ req.params = {
10
+ auth_token: user.auth_token,
11
+ token: project_token
12
+ }
13
+ end
14
+ end
15
+
16
+ def create(attrs, user = @@default_user)
17
+ attrs = { project_token: @project_token }.merge(attrs)
18
+ @attributes = send_request('test_runs', :post) do |req|
19
+ req.body = {
20
+ test_run: attrs.except(:project_token),
21
+ token: attrs[:project_token],
22
+ auth_token: user.auth_token
23
+ }
24
+ end
25
+ end
26
+
27
+ def show(project_token = @project_token, id = @id, user = @@default_user)
28
+ @attributes = send_request("test_runs/#{id}", :get) do |req|
29
+ req.params = {
30
+ token: project_token,
31
+ auth_token: user.auth_token
32
+ }
33
+ end
34
+ end
35
+
36
+ def update(attrs, user = @@default_user)
37
+ attrs = { id: @id, project_token: @project_token }.merge(attrs)
38
+ @attributes = send_request("test_runs/#{attrs[:id]}", :put) do |req|
39
+ req.body = {
40
+ test_run: attrs.except(:project_token, :id),
41
+ token: attrs[:project_token],
42
+ auth_token: user.auth_token
43
+ }
44
+ end
45
+ end
46
+
47
+ def delete(project_token = @project_token, id = @id, user = @@default_user)
48
+ @attributes = send_request("test_runs/#{id}", :delete) do |req|
49
+ req.params = {
50
+ token: project_token,
51
+ auth_token: user.auth_token
52
+ }
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,56 @@
1
+ module EasyqaApi
2
+ class TestRunResult < Item
3
+ attr_accessor :id, :attributes, :project_token, :test_run_id
4
+
5
+ install_class_methods!
6
+
7
+ def self.all(project_token, test_run_id, user = @@default_user)
8
+ send_request("test_runs/#{test_run_id}/test_run_results", :get) do |req|
9
+ req.params = {
10
+ auth_token: user.auth_token,
11
+ token: project_token
12
+ }
13
+ end
14
+ end
15
+
16
+ def create(attrs, user = @@default_user)
17
+ attrs = { project_token: @project_token, test_run_id: @test_run_id }.merge(attrs)
18
+ @attributes = send_request("test_runs/#{attrs[:test_run_id]}/test_run_results", :post) do |req|
19
+ req.body = {
20
+ test_run_result: attrs.except(:project_token, :test_run_id),
21
+ token: attrs[:project_token],
22
+ auth_token: user.auth_token
23
+ }
24
+ end
25
+ end
26
+
27
+ def show(project_token = @project_token, id = @id, user = @@default_user)
28
+ @attributes = send_request("test_run_results/#{id}", :get) do |req|
29
+ req.params = {
30
+ token: project_token,
31
+ auth_token: user.auth_token
32
+ }
33
+ end
34
+ end
35
+
36
+ def update(attrs, user = @@default_user)
37
+ attrs = { id: @id, project_token: @project_token }.merge(attrs)
38
+ @attributes = send_request("test_run_results/#{attrs[:id]}", :put) do |req|
39
+ req.body = {
40
+ test_run_result: attrs.except(:project_token, :id),
41
+ token: attrs[:project_token],
42
+ auth_token: user.auth_token
43
+ }
44
+ end
45
+ end
46
+
47
+ def delete(project_token = @project_token, id = @id, user = @@default_user)
48
+ @attributes = send_request("test_run_results/#{id}", :delete) do |req|
49
+ req.params = {
50
+ token: project_token,
51
+ auth_token: user.auth_token
52
+ }
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,33 @@
1
+ module EasyqaApi
2
+ class User < Item
3
+ attr_accessor :auth_token, :name
4
+
5
+ def initialize(attrs = {})
6
+ super
7
+ install_variables!(
8
+ attrs[:email] && attrs[:password] ? sign_in(attrs[:email], attrs[:password]) : attrs
9
+ )
10
+ end
11
+
12
+ def sign_in(email, password)
13
+ send_request('sign_in', :post) do |req|
14
+ req.body = {
15
+ user: {
16
+ email: email,
17
+ password: password
18
+ }
19
+ }
20
+ end
21
+ end
22
+
23
+ def sign_out
24
+ send_request('sign_out', :delete) do |req|
25
+ req.body = { auth_token: auth_token || @auth_token }
26
+ end
27
+ end
28
+
29
+ def set_default!
30
+ @@default_user = self
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module EasyqaApi
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: easyqa_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Thinkmobiles
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-04-07 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.9.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday_middleware
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.10.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.10.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: activesupport
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '5.0'
90
+ - - ">"
91
+ - !ruby/object:Gem::Version
92
+ version: '4.0'
93
+ type: :runtime
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '5.0'
100
+ - - ">"
101
+ - !ruby/object:Gem::Version
102
+ version: '4.0'
103
+ description: Simple gem for EasyQA API
104
+ email:
105
+ - gashuk95@gmail.com
106
+ executables: []
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - ".gitignore"
111
+ - ".rspec"
112
+ - ".travis.yml"
113
+ - CODE_OF_CONDUCT.md
114
+ - Gemfile
115
+ - README.md
116
+ - Rakefile
117
+ - bin/console
118
+ - bin/setup
119
+ - easyqa_api.gemspec
120
+ - lib/easyqa_api.rb
121
+ - lib/easyqa_api/configuration.rb
122
+ - lib/easyqa_api/exceptions.rb
123
+ - lib/easyqa_api/helpers/class_methods_settable.rb
124
+ - lib/easyqa_api/helpers/easyqa_api_helper.rb
125
+ - lib/easyqa_api/item.rb
126
+ - lib/easyqa_api/items/issue.rb
127
+ - lib/easyqa_api/items/issue_attachment.rb
128
+ - lib/easyqa_api/items/organization.rb
129
+ - lib/easyqa_api/items/project.rb
130
+ - lib/easyqa_api/items/role.rb
131
+ - lib/easyqa_api/items/status.rb
132
+ - lib/easyqa_api/items/test_case.rb
133
+ - lib/easyqa_api/items/test_module.rb
134
+ - lib/easyqa_api/items/test_object.rb
135
+ - lib/easyqa_api/items/test_plan.rb
136
+ - lib/easyqa_api/items/test_run.rb
137
+ - lib/easyqa_api/items/test_run_result.rb
138
+ - lib/easyqa_api/items/user.rb
139
+ - lib/easyqa_api/version.rb
140
+ homepage: https://app.geteasyqa.com/
141
+ licenses: []
142
+ metadata:
143
+ allowed_push_host: https://rubygems.org
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ requirements: []
159
+ rubyforge_project:
160
+ rubygems_version: 2.5.1
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: API to EasyQA
164
+ test_files: []