rodzilla 0.1.0
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 +15 -0
- data/.gitignore +17 -0
- data/.ruby-gemset +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +63 -0
- data/Rakefile +12 -0
- data/lib/rodzilla.rb +49 -0
- data/lib/rodzilla/exception.rb +4 -0
- data/lib/rodzilla/resource/base.rb +73 -0
- data/lib/rodzilla/resource/bug.rb +52 -0
- data/lib/rodzilla/resource/bugzilla.rb +23 -0
- data/lib/rodzilla/resource/classification.rb +15 -0
- data/lib/rodzilla/resource/product.rb +25 -0
- data/lib/rodzilla/version.rb +9 -0
- data/rodzilla.gemspec +29 -0
- data/test/rodzilla/resource/base_test.rb +86 -0
- data/test/rodzilla/resource/bug_test.rb +44 -0
- data/test/rodzilla/web_service_test.rb +60 -0
- data/test/test_helper.rb +3 -0
- metadata +165 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NzllNmM3NjE0MDdhZjllM2I1YTUxMWZhNzAwNmNmNjZiZjlhZjg1Yw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NmQyOWIyNjBjZGRlNDYyN2RlZDliN2U4YjQ4OGQ1NjQ1MTczODk1OA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzBiOWExODRlMzQyNGEzMDY0NDUwODNjNWM4YzZhYzk2ZTZkNzViZWIwZTYz
|
10
|
+
MzlmOWRmODFhZmQ0MGI2NGYwYmIxZjM3NzI1OWNiODZlN2JhM2U4NmM2YTBl
|
11
|
+
Y2JmMTM1ODFhM2Q4ZTc3YzI5NzljZDE5ZTc0M2NjNzIzN2E1ZTE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NzMwMGM4ZTIxNjU3YjA1YTc4OTRhM2M3ZWY3NmI1ZmY0ZTk4MjYwZjE0ODcz
|
14
|
+
MTkyN2UxNTVkZjNjYjc3N2UzODYyNGJmMzFlMTU5MjhkNTM3NzRiNjBiMDZk
|
15
|
+
NTNkZTk4MTg2YTkwYzBlZTllYjc3OTM2ODVhZjAwOWI1MDMzMWE=
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rodzilla
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 John Faucett
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Rodzilla
|
2
|
+
|
3
|
+
This Ruby Gem tries its best to implement: [http://www.bugzilla.org/docs/tip/en/html/api/index.html](The Bugzilla API)
|
4
|
+
|
5
|
+
It only supports JSON and implements json-rpc
|
6
|
+
The JSON-RPC specification: [http://json-rpc.org/wiki/specification](JSON-RPC Specification)
|
7
|
+
|
8
|
+
Currently the Bugzilla REST API is experimental and not reliable, so this is not a REST API.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'rodzilla'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install rodzilla
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
````ruby
|
27
|
+
# get the Bugzilla list of available projects
|
28
|
+
require "rodzilla"
|
29
|
+
service = Rodzilla::WebService.new("https://example.com", "username", "password")
|
30
|
+
product_ids = service.products.get_accessible_products
|
31
|
+
service.products.get_products(product_ids) # OpenStruct.products -> "Array of all products with names and extra info"
|
32
|
+
|
33
|
+
# Find out specific information about required bug fields
|
34
|
+
service.bugs.fields
|
35
|
+
|
36
|
+
# There is also an alternative method for rpc resources objects
|
37
|
+
bug = Rodzilla::Resource::Bug.new("https://example.com", "username", "password", :json )
|
38
|
+
bug.fields
|
39
|
+
|
40
|
+
# Searching is also easy
|
41
|
+
# for more info see: http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html#search
|
42
|
+
bug.search( product: [ 'Test-Product' ] )
|
43
|
+
|
44
|
+
# Bug Creation
|
45
|
+
service.bugs.create!( product: 'Demo Product',
|
46
|
+
component: 'Some Component',
|
47
|
+
summary: 'demo bla di bla',
|
48
|
+
description: 'demo bladi bla',
|
49
|
+
op_sys: 'iPhone OS',
|
50
|
+
platform: 'PC',
|
51
|
+
priority: 'High',
|
52
|
+
severity: 'minor',
|
53
|
+
version: 'unspecified'
|
54
|
+
) # => { "id" => 9832 }
|
55
|
+
````
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
1. Fork it
|
60
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
61
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
62
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
63
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
desc 'Default: run unit tests.'
|
5
|
+
task default: :test
|
6
|
+
|
7
|
+
desc 'Test the rodzilla client.'
|
8
|
+
Rake::TestTask.new(:test) do |t|
|
9
|
+
t.libs << 'lib' << 'test'
|
10
|
+
t.test_files = FileList['test/**/*_test.rb']
|
11
|
+
t.verbose = true
|
12
|
+
end
|
data/lib/rodzilla.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require "httparty"
|
2
|
+
require "json"
|
3
|
+
require "rodzilla/version"
|
4
|
+
require "rodzilla/exception"
|
5
|
+
|
6
|
+
# load resources
|
7
|
+
require "rodzilla/resource/base"
|
8
|
+
require "rodzilla/resource/product"
|
9
|
+
require "rodzilla/resource/classification"
|
10
|
+
require "rodzilla/resource/bugzilla"
|
11
|
+
require "rodzilla/resource/bug"
|
12
|
+
|
13
|
+
module Rodzilla
|
14
|
+
class WebService
|
15
|
+
|
16
|
+
attr_accessor :base_url, :username, :password, :format
|
17
|
+
|
18
|
+
def initialize(base_url, username, password, format=:json)
|
19
|
+
@base_url = base_url
|
20
|
+
@username = username
|
21
|
+
@password = password
|
22
|
+
@format = format
|
23
|
+
end
|
24
|
+
|
25
|
+
def products
|
26
|
+
bugzilla_resource('Product')
|
27
|
+
end
|
28
|
+
|
29
|
+
def bugzilla
|
30
|
+
bugzilla_resource('Bugzilla')
|
31
|
+
end
|
32
|
+
|
33
|
+
def classifications
|
34
|
+
bugzilla_resource('Classification')
|
35
|
+
end
|
36
|
+
|
37
|
+
def bugs
|
38
|
+
bugzilla_resource('Bug')
|
39
|
+
end
|
40
|
+
|
41
|
+
protected
|
42
|
+
def bugzilla_resource(resource)
|
43
|
+
raise Rodzilla::ResourceNotFoundError, "Error: #{resource} not found." unless Rodzilla::Resource.constants.include?(resource.to_sym)
|
44
|
+
klass = Object.module_eval("Rodzilla::Resource::#{resource}").new(@base_url, @username, @password, @format)
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Rodzilla
|
2
|
+
module Resource
|
3
|
+
class Base
|
4
|
+
@@_request_id = 1
|
5
|
+
include HTTParty
|
6
|
+
attr_accessor :base_url, :username, :password, :format,
|
7
|
+
:request_url, :response, :result, :credentials, :headers
|
8
|
+
|
9
|
+
def initialize(base_url, username, password, format=:json)
|
10
|
+
@base_url = base_url
|
11
|
+
@username = username
|
12
|
+
@password = password
|
13
|
+
@format = format
|
14
|
+
@credentials = {
|
15
|
+
Bugzilla_login: @username,
|
16
|
+
Bugzilla_password: @password
|
17
|
+
}
|
18
|
+
@headers = { "Content-Type" => 'application/json-rpc' }
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def prepare_request(params={})
|
26
|
+
@request_url = build_url
|
27
|
+
@params = build_params(params)
|
28
|
+
end
|
29
|
+
|
30
|
+
def build_url
|
31
|
+
File.join("#{@base_url}", "#{@format}rpc.cgi")
|
32
|
+
end
|
33
|
+
|
34
|
+
def build_params(params={})
|
35
|
+
rpc_method = params.delete(:rpc_method)
|
36
|
+
{ params: [@credentials.merge(params)], method: "#{self.class.demodulize(self.class)}.#{rpc_method}", id: make_id }
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.demodulize(path)
|
40
|
+
path = path.to_s
|
41
|
+
if i = path.rindex('::')
|
42
|
+
path[(i+2)..-1]
|
43
|
+
else
|
44
|
+
path
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def make_id
|
49
|
+
@@_request_id += 1
|
50
|
+
end
|
51
|
+
|
52
|
+
def rpc_call(params={})
|
53
|
+
prepare_request( params )
|
54
|
+
@response = self.class.post(@request_url, body: JSON.dump(@params), headers: @headers )
|
55
|
+
parse_rpc_response!
|
56
|
+
end
|
57
|
+
|
58
|
+
def parse_rpc_response!
|
59
|
+
begin
|
60
|
+
res = @response.parsed_response
|
61
|
+
if err = res["error"]
|
62
|
+
raise Rodzilla::JsonRpcResponseError, "Error (#{err['code']}): #{err['message']}"
|
63
|
+
end
|
64
|
+
@result = res["result"]
|
65
|
+
rescue => ex
|
66
|
+
raise ex
|
67
|
+
end
|
68
|
+
@result
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Rodzilla
|
2
|
+
module Resource
|
3
|
+
class Bug < Base
|
4
|
+
REQUIRED_FIELDS = [:product, :component, :summary, :version, :description, :op_sys, :platform, :priority, :severity]
|
5
|
+
|
6
|
+
def fields
|
7
|
+
rpc_call( rpc_method: "fields" )
|
8
|
+
end
|
9
|
+
|
10
|
+
# Unless otherwise specified in the description of a parameter,
|
11
|
+
# bugs are returned if they match exactly the criteria you specify in these parameters.
|
12
|
+
# That is, we don't match against substrings--if a bug is in the "Widgets" product and you ask for bugs in the "Widg" product, you won't get anything.
|
13
|
+
#
|
14
|
+
# Criteria are joined in a logical AND.
|
15
|
+
# That is, you will be returned bugs that match all of the criteria, not bugs that match any of the criteria.
|
16
|
+
#
|
17
|
+
# Each parameter can be either the type it says, or an array of the types it says.
|
18
|
+
# If you pass an array, it means "Give me bugs with any of these values."
|
19
|
+
# For example, if you wanted bugs that were in either the "Foo" or "Bar" products, you'd pass:
|
20
|
+
#
|
21
|
+
# Valid values:
|
22
|
+
# product, url, id, alias, limit
|
23
|
+
def search(query={})
|
24
|
+
rpc_call( query.merge(rpc_method: 'search') )
|
25
|
+
end
|
26
|
+
|
27
|
+
# see: http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html#create
|
28
|
+
#
|
29
|
+
# Required Fields:
|
30
|
+
# product (string) Required - The name of the product the bug is being filed against.
|
31
|
+
# component (string) Required - The name of a component in the product above.
|
32
|
+
# summary (string) Required - A brief description of the bug being filed.
|
33
|
+
# version (string) Required - A version of the product above; the version the bug was found in.
|
34
|
+
# description (string) Defaulted - The initial description for this bug. Some Bugzilla installations require this to not be blank.
|
35
|
+
# op_sys (string) Defaulted - The operating system the bug was discovered on.
|
36
|
+
# platform (string) Defaulted - What type of hardware the bug was experienced on.
|
37
|
+
# priority (string) Defaulted - What order the bug will be fixed in by the developer, compared to the developer's other bugs.
|
38
|
+
# severity (string) Defaulted - How severe the bug is.
|
39
|
+
#
|
40
|
+
# Raises an exception if a required field is not provided
|
41
|
+
def create!(params={})
|
42
|
+
REQUIRED_FIELDS.each { |field| raise ArgumentError, "Error: #{field} is required" unless params[field] }
|
43
|
+
rpc_call( params.merge(rpc_method: 'create' ))
|
44
|
+
end
|
45
|
+
|
46
|
+
def create(params={})
|
47
|
+
rpc_call( params.merge(rpc_method: 'create'))
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Rodzilla
|
2
|
+
module Resource
|
3
|
+
class Bugzilla < Base
|
4
|
+
|
5
|
+
def version
|
6
|
+
rpc_call( rpc_method: 'version' )
|
7
|
+
end
|
8
|
+
|
9
|
+
def time
|
10
|
+
rpc_call( rpc_method: 'time' )
|
11
|
+
end
|
12
|
+
|
13
|
+
def timezone
|
14
|
+
rpc_call( rpc_method: 'timezone' )
|
15
|
+
end
|
16
|
+
|
17
|
+
def extensions
|
18
|
+
rpc_call( rpc_method: 'extensions' )
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Rodzilla
|
2
|
+
module Resource
|
3
|
+
# Bugzilla::Webservice::Classification - The Classification API
|
4
|
+
# This part of the Bugzilla API allows you to deal with the available Classifications.
|
5
|
+
# You will be able to get information about them as well as manipulate them.
|
6
|
+
class Classification < Base
|
7
|
+
|
8
|
+
# Returns a hash containing information about a set of classifications.
|
9
|
+
def get(ids)
|
10
|
+
rpc_call( rpc_method: "get", ids: ids )
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Rodzilla
|
2
|
+
module Resource
|
3
|
+
# Bugzilla::Webservice::Product - The Product API
|
4
|
+
# This part of the Bugzilla API allows you to list the available Products and get information about them.
|
5
|
+
class Product < Base
|
6
|
+
|
7
|
+
# Returns a list of the ids of the products the user can search on.
|
8
|
+
def get_selectable_products
|
9
|
+
rpc_call( rpc_method: "get_selectable_products" )
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_enterable_products
|
13
|
+
rpc_call( rpc_method: "get_enterable_products" )
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_accessible_products
|
17
|
+
rpc_call( rpc_method: "get_accessible_products" )
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_products(ids)
|
21
|
+
rpc_call( rpc_method: "get", ids: ids )
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/rodzilla.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rodzilla/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rodzilla"
|
8
|
+
spec.version = Rodzilla::VERSION::STRING
|
9
|
+
spec.authors = ["John Faucett"]
|
10
|
+
spec.email = ["jwaterfaucett@gmail.com"]
|
11
|
+
spec.description = %q{A Bugzilla ReST API Client}
|
12
|
+
spec.summary = %q{Bugzilla API Client}
|
13
|
+
spec.homepage = "https://github.com/jwaterfaucett/rodzilla"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "httparty"
|
22
|
+
spec.add_dependency "libxml-ruby"
|
23
|
+
spec.add_dependency "yajl-ruby"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "minitest"
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
spec.add_development_dependency "debugger", "~> 1.6.2"
|
29
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
|
4
|
+
describe Rodzilla::Resource::Base do
|
5
|
+
before do
|
6
|
+
@base = Rodzilla::Resource::Base.new('http://example.io', 'uname', 'passwd')
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "instance" do
|
10
|
+
|
11
|
+
it "has base_url accessors" do
|
12
|
+
@base.must_respond_to('base_url')
|
13
|
+
@base.must_respond_to('base_url=')
|
14
|
+
end
|
15
|
+
|
16
|
+
it "has username accessors" do
|
17
|
+
@base.must_respond_to('username')
|
18
|
+
@base.must_respond_to('username=')
|
19
|
+
end
|
20
|
+
|
21
|
+
it "has password accessors" do
|
22
|
+
@base.must_respond_to('password')
|
23
|
+
@base.must_respond_to('password=')
|
24
|
+
end
|
25
|
+
|
26
|
+
it "has format accessors" do
|
27
|
+
@base.must_respond_to('format')
|
28
|
+
@base.must_respond_to('format=')
|
29
|
+
end
|
30
|
+
|
31
|
+
it "has request_url accessors" do
|
32
|
+
@base.must_respond_to('request_url')
|
33
|
+
@base.must_respond_to('request_url=')
|
34
|
+
end
|
35
|
+
|
36
|
+
it "has response accessors" do
|
37
|
+
@base.must_respond_to('response')
|
38
|
+
@base.must_respond_to('response=')
|
39
|
+
end
|
40
|
+
|
41
|
+
it "has result accessors" do
|
42
|
+
@base.must_respond_to('result')
|
43
|
+
@base.must_respond_to('result=')
|
44
|
+
end
|
45
|
+
|
46
|
+
it "has credentials accessors" do
|
47
|
+
@base.must_respond_to('credentials')
|
48
|
+
@base.must_respond_to('credentials=')
|
49
|
+
end
|
50
|
+
|
51
|
+
it "has headers accessors" do
|
52
|
+
@base.must_respond_to('headers')
|
53
|
+
@base.must_respond_to('headers=')
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "class methods" do
|
57
|
+
it "has a demodularize method" do
|
58
|
+
Rodzilla::Resource::Base.must_respond_to(:demodulize)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "protected_methods" do
|
63
|
+
it "has a prepare_request method" do
|
64
|
+
@base.protected_methods.must_include(:prepare_request)
|
65
|
+
end
|
66
|
+
it "has a build_url method" do
|
67
|
+
@base.protected_methods.must_include(:build_url)
|
68
|
+
end
|
69
|
+
it "has a build_params method" do
|
70
|
+
@base.protected_methods.must_include(:build_params)
|
71
|
+
end
|
72
|
+
it "has a make_id method" do
|
73
|
+
@base.protected_methods.must_include(:make_id)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "has a rpc_call method" do
|
77
|
+
@base.protected_methods.must_include(:rpc_call)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "has a parse_rpc_response! method" do
|
81
|
+
@base.protected_methods.must_include(:parse_rpc_response!)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Rodzilla::Resource::Bug do
|
4
|
+
before do
|
5
|
+
@bug = Rodzilla::Resource::Bug.new('http://asdf.net', 'asdf', 'asdf', :json)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "bug instance" do
|
9
|
+
it "should inherit from Rodzilla::Resource::Base" do
|
10
|
+
@bug.class.superclass.must_equal(Rodzilla::Resource::Base)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should respond_to create" do
|
14
|
+
@bug.must_respond_to(:create)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should respond_to create!" do
|
18
|
+
@bug.must_respond_to(:create!)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should respond_to fields" do
|
22
|
+
@bug.must_respond_to(:fields)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should respond_to search" do
|
26
|
+
@bug.must_respond_to(:search)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "validations" do
|
32
|
+
|
33
|
+
it "should have all Bugzilla REQUIRED_FIELDS for bug creation" do
|
34
|
+
Rodzilla::Resource::Bug.constants.must_include(:REQUIRED_FIELDS)
|
35
|
+
[:product, :component, :summary,
|
36
|
+
:version, :description, :op_sys,
|
37
|
+
:platform, :priority, :severity].each do |field|
|
38
|
+
Rodzilla::Resource::Bug::REQUIRED_FIELDS.must_include(field)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Rodzilla::WebService do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@service = Rodzilla::WebService.new('http://example.io', 'asdf', 'asdf')
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
@service
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "initialization" do
|
14
|
+
it "should accept 4 parameters: base_url, username, password, and format" do
|
15
|
+
s = Rodzilla::WebService.new('http://example.io', 'uname', 'passwd', :json)
|
16
|
+
s.username.must_equal('uname')
|
17
|
+
s.password.must_equal('passwd')
|
18
|
+
s.base_url.must_equal('http://example.io')
|
19
|
+
s.format.must_equal(:json)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should raise an ArgumentError if base_url, username, and password are not given" do
|
23
|
+
Proc.new do
|
24
|
+
Rodzilla::WebService.new('http://example.io', 'uname')
|
25
|
+
end.must_raise(ArgumentError)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should by default set the format to json" do
|
29
|
+
s = Rodzilla::WebService.new('http://example.io', 'uname', 'passwd')
|
30
|
+
s.format.must_equal(:json)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "instance methods" do
|
35
|
+
|
36
|
+
it "products should return ::Resource::Product class" do
|
37
|
+
@service.products.must_be_kind_of(Rodzilla::Resource::Product)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "bugs should return a Resource::Bug class" do
|
41
|
+
@service.bugs.must_be_kind_of(Rodzilla::Resource::Bug)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "bugzilla should return a Resource::Bugzilla class" do
|
45
|
+
@service.bugzilla.must_be_kind_of(Rodzilla::Resource::Bugzilla)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "classifications should return a Resource::Classification class" do
|
49
|
+
@service.classifications.must_be_kind_of(Rodzilla::Resource::Classification)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "bugzilla_resource should raise a Rodzilla::ResourceNotFoundError exception for undefined resources" do
|
53
|
+
Proc.new do
|
54
|
+
@service.send(:bugzilla_resource, "Nada")
|
55
|
+
end.must_raise(Rodzilla::ResourceNotFoundError)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rodzilla
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Faucett
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: libxml-ruby
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: yajl-ruby
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: debugger
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.6.2
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.6.2
|
111
|
+
description: A Bugzilla ReST API Client
|
112
|
+
email:
|
113
|
+
- jwaterfaucett@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- .ruby-gemset
|
120
|
+
- Gemfile
|
121
|
+
- LICENSE.txt
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- lib/rodzilla.rb
|
125
|
+
- lib/rodzilla/exception.rb
|
126
|
+
- lib/rodzilla/resource/base.rb
|
127
|
+
- lib/rodzilla/resource/bug.rb
|
128
|
+
- lib/rodzilla/resource/bugzilla.rb
|
129
|
+
- lib/rodzilla/resource/classification.rb
|
130
|
+
- lib/rodzilla/resource/product.rb
|
131
|
+
- lib/rodzilla/version.rb
|
132
|
+
- rodzilla.gemspec
|
133
|
+
- test/rodzilla/resource/base_test.rb
|
134
|
+
- test/rodzilla/resource/bug_test.rb
|
135
|
+
- test/rodzilla/web_service_test.rb
|
136
|
+
- test/test_helper.rb
|
137
|
+
homepage: https://github.com/jwaterfaucett/rodzilla
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
metadata: {}
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ! '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 2.0.7
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: Bugzilla API Client
|
161
|
+
test_files:
|
162
|
+
- test/rodzilla/resource/base_test.rb
|
163
|
+
- test/rodzilla/resource/bug_test.rb
|
164
|
+
- test/rodzilla/web_service_test.rb
|
165
|
+
- test/test_helper.rb
|