ticketmaster 0.3.2 → 0.3.3
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.
- data/LICENSE +1 -1
- data/Rakefile +14 -17
- data/VERSION +1 -1
- data/lib/ticketmaster/cli/commands/console.rb +1 -1
- data/lib/ticketmaster/cli/common.rb +2 -1
- data/lib/ticketmaster/cli/init.rb +1 -1
- data/lib/ticketmaster/common.rb +3 -4
- data/lib/ticketmaster/dummy/comment.rb +27 -0
- data/lib/ticketmaster/dummy/dummy.rb +1 -38
- data/lib/ticketmaster/dummy/project.rb +12 -29
- data/lib/ticketmaster/dummy/ticket.rb +8 -19
- data/lib/ticketmaster/helper.rb +3 -3
- data/lib/ticketmaster/provider.rb +5 -0
- data/lib/ticketmaster.rb +2 -0
- data/spec/project_spec.rb +149 -0
- data/spec/rcov.opts +1 -0
- data/spec/ticket_spec.rb +74 -0
- data/spec/ticketmaster_spec.rb +5 -39
- data/ticketmaster.gemspec +13 -9
- metadata +26 -11
- data/test/helper.rb +0 -10
- data/test/test_ticketmaster.rb +0 -4
data/LICENSE
CHANGED
data/Rakefile
CHANGED
@@ -11,6 +11,7 @@ begin
|
|
11
11
|
gem.homepage = "http://ticketrb.com"
|
12
12
|
gem.authors = ["Sirupsen", "deadprogrammer"]
|
13
13
|
gem.add_dependency "hashie", ">= 0"
|
14
|
+
gem.add_dependency "activeresource", ">= 0"
|
14
15
|
gem.add_development_dependency "shoulda", ">= 0"
|
15
16
|
end
|
16
17
|
Jeweler::GemcutterTasks.new
|
@@ -18,29 +19,25 @@ rescue LoadError
|
|
18
19
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
|
23
|
+
require 'spec/rake/spectask'
|
24
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
25
|
+
spec.libs << 'lib' << 'spec'
|
26
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
rescue LoadError
|
36
|
-
task :rcov do
|
37
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
29
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
30
|
+
spec.libs << 'lib' << 'spec'
|
31
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
32
|
+
spec.rcov = true
|
33
|
+
spec.rcov_opts = lambda do
|
34
|
+
IO.readlines("spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
38
35
|
end
|
39
36
|
end
|
40
37
|
|
41
|
-
task :
|
38
|
+
task :spec => :check_dependencies
|
42
39
|
|
43
|
-
task :default => :
|
40
|
+
task :default => :spec
|
44
41
|
|
45
42
|
require 'rake/rdoctask'
|
46
43
|
Rake::RDocTask.new do |rdoc|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
@@ -16,7 +16,7 @@ def open_irb(options, argv)
|
|
16
16
|
providers.delete 'default'
|
17
17
|
require 'rubygems'
|
18
18
|
require 'ticketmaster'
|
19
|
-
providers.
|
19
|
+
providers.inject(requires) do |mem, p|
|
20
20
|
begin
|
21
21
|
require "ticketmaster-#{p}"
|
22
22
|
requires << "-r ticketmaster-#{p} "
|
@@ -11,8 +11,9 @@ end
|
|
11
11
|
|
12
12
|
# A utility method used to separate name:value pairs
|
13
13
|
def attributes_hash(kvlist)
|
14
|
+
require 'enumerator' if RUBY_VERSION < "1.8.7"
|
14
15
|
if kvlist.is_a?(String)
|
15
|
-
kvlist.split(',').
|
16
|
+
kvlist.split(',').inject({}) do |mem, kv|
|
16
17
|
key, value = kv.split(':')
|
17
18
|
mem[key] = value
|
18
19
|
mem
|
@@ -14,7 +14,7 @@ commands ={ 'help' => 'Get the help text for a particular command',
|
|
14
14
|
|
15
15
|
helptext = lambda {
|
16
16
|
helpmsg = "\nAvailable commands:\n"
|
17
|
-
commands.sort.
|
17
|
+
commands.sort.inject(helpmsg) { |mem, cmd| mem << "\t#{cmd.join("\t\t")}\n" }
|
18
18
|
helpmsg << "\nSee 'ticket help COMMAND' for more information on a specific command."
|
19
19
|
}
|
20
20
|
|
data/lib/ticketmaster/common.rb
CHANGED
@@ -29,13 +29,12 @@ module TicketMaster::Provider
|
|
29
29
|
@cache ||= {}
|
30
30
|
first = options.shift
|
31
31
|
case first
|
32
|
-
when
|
32
|
+
when Hash
|
33
|
+
super(first.to_hash)
|
34
|
+
else
|
33
35
|
@system_data[:client] = first
|
34
36
|
self.prefix_options ||= @system_data[:client].prefix_options if @system_data[:client].prefix_options
|
35
37
|
super(first.attributes)
|
36
|
-
|
37
|
-
when Hash
|
38
|
-
super(first.to_hash)
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module TicketMaster::Provider
|
2
|
+
module Dummy
|
3
|
+
# This is the Comment class for the Dummy provider
|
4
|
+
class Comment < TicketMaster::Provider::Base::Comment
|
5
|
+
|
6
|
+
|
7
|
+
def self.find_by_id(id)
|
8
|
+
self.new({:id => id})
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.find_by_attributes(*options)
|
12
|
+
[self.new(*options)]
|
13
|
+
end
|
14
|
+
|
15
|
+
# You don't need to define an initializer, this is only here to initialize dummy data
|
16
|
+
def initialize(project_id, ticket_id, *options)
|
17
|
+
data = {:id => rand(1000), :status => ['lol', 'rofl', 'lmao', 'lamo', 'haha', 'heh'][rand(6)],
|
18
|
+
:priority => rand(10), :summary => 'Tickets ticket ticket ticket', :resolution => false,
|
19
|
+
:created_at => Time.now, :updated_at => Time.now, :description => 'Ticket ticket ticket ticket laughing',
|
20
|
+
:assignee => 'lol-man'}
|
21
|
+
@system = :dummy
|
22
|
+
super(data.merge(options.first || {}))
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -14,52 +14,15 @@ module TicketMaster::Provider
|
|
14
14
|
# around the TicketMaster.new call.
|
15
15
|
module Dummy
|
16
16
|
include TicketMaster::Provider::Base
|
17
|
-
@system = :dummy
|
18
17
|
# An example of what to do if you would like to do TicketMaster::Provider::Dummy.new(...)
|
19
18
|
# rather than TicketMaster.new(:dummy, ...)
|
20
19
|
def self.new(authentication = {})
|
21
20
|
TicketMaster.new(:dummy, authentication)
|
22
21
|
# maybe do some other stuff
|
23
22
|
end
|
24
|
-
|
25
|
-
# It returns all projects...
|
26
|
-
def projects(*options)
|
27
|
-
return Project.find(*options) if options.length > 0
|
28
|
-
[Project.new]
|
29
|
-
end
|
30
|
-
|
31
|
-
# It returns all tickets...
|
32
|
-
def tickets(*options)
|
33
|
-
return Ticket.find(*options) if options.length > 0
|
34
|
-
[Ticket.new]
|
35
|
-
end
|
36
|
-
|
37
|
-
# Returning a single ticket based on parameters or a Ticket class if no parameters given
|
38
|
-
#
|
39
|
-
# The later is for doing:
|
40
|
-
# ticketmaster.ticket.find(...)
|
41
|
-
# ticketmaster.tickets.create(...)
|
42
|
-
#
|
43
|
-
# It's semantically nicer to use ticketmaster.tickets.find ... but people do strange things...
|
44
|
-
def ticket(*options)
|
45
|
-
return Ticket.new(*options) if options.length > 0
|
46
|
-
TicketMaster::Provider::Dummy::Ticket
|
47
|
-
end
|
48
|
-
|
49
|
-
# Return a single project based on parameters or the Project class if no parameters given
|
50
|
-
#
|
51
|
-
# The later is for doing:
|
52
|
-
# ticketmaster.project.find(...)
|
53
|
-
# ticketmaster.tickets.create(...)
|
54
|
-
#
|
55
|
-
# (It's semantically nicer to use ticketmaster.projects.find ... but people do strange things)
|
56
|
-
def project(*options)
|
57
|
-
return Project.new(*options) if options.length > 0
|
58
|
-
TicketMaster::Provider::Dummy::Project
|
59
|
-
end
|
60
23
|
end
|
61
24
|
end
|
62
25
|
|
63
|
-
%w| project ticket |.each do |f|
|
26
|
+
%w| project ticket comment |.each do |f|
|
64
27
|
require File.dirname(__FILE__) + '/' + f +'.rb'
|
65
28
|
end
|
@@ -2,22 +2,17 @@ module TicketMaster::Provider
|
|
2
2
|
module Dummy
|
3
3
|
# This is the Project class for the Dummy provider
|
4
4
|
class Project < TicketMaster::Provider::Base::Project
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
elsif first == :first
|
17
|
-
Project.new(options.shift)
|
18
|
-
elsif first.is_a?(Hash)
|
19
|
-
[Project.new(first)]
|
20
|
-
end
|
5
|
+
|
6
|
+
def self.find_by_id(id)
|
7
|
+
self.new({:id => id})
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.find_by_attributes(*options)
|
11
|
+
[self.new(*options)]
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.create(*attributes)
|
15
|
+
self.new(*attributes)
|
21
16
|
end
|
22
17
|
|
23
18
|
# You should define @system and @system_data here.
|
@@ -31,18 +26,6 @@ module TicketMaster::Provider
|
|
31
26
|
super(data.merge(options.first || {}))
|
32
27
|
end
|
33
28
|
|
34
|
-
# Should return all of the project's tickets
|
35
|
-
def tickets(*options)
|
36
|
-
return Ticket.find(*options) if options.length > 0
|
37
|
-
[Ticket.new]
|
38
|
-
end
|
39
|
-
|
40
|
-
# Point it to the Dummy's Ticket class
|
41
|
-
def ticket(*options)
|
42
|
-
return Ticket.find(:first, options.first) if options.length > 0
|
43
|
-
Ticket
|
44
|
-
end
|
45
|
-
|
46
29
|
# Nothing to save so we always return true
|
47
30
|
# ...unless it's an odd numbered second on Friday the 13th. muhaha!
|
48
31
|
def save
|
@@ -51,7 +34,7 @@ module TicketMaster::Provider
|
|
51
34
|
end
|
52
35
|
|
53
36
|
# Nothing to update, so we always return true
|
54
|
-
def update(*options)
|
37
|
+
def update!(*options)
|
55
38
|
return true
|
56
39
|
end
|
57
40
|
end
|
@@ -4,31 +4,20 @@ module TicketMaster::Provider
|
|
4
4
|
class Ticket < TicketMaster::Provider::Base::Ticket
|
5
5
|
@system = :dummy
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# * find(:first, :summary => 'Ticket title') - Returns a ticket based on the ticket's attributes
|
14
|
-
# * find(:summary => 'Test Ticket') - Returns all tickets based on the given attributes
|
15
|
-
def self.find(*options)
|
16
|
-
first = options.shift
|
17
|
-
if first.nil? or first == :all
|
18
|
-
[Ticket.new]
|
19
|
-
elsif first == :first
|
20
|
-
Ticket.new(options.shift)
|
21
|
-
elsif first.is_a?(Hash)
|
22
|
-
[Ticket.new(first)]
|
23
|
-
end
|
7
|
+
def self.find_by_id(project_id, ticket_id)
|
8
|
+
self.new(project_id, {:id => ticket_id})
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.find_by_attributes(*ticket_attributes)
|
12
|
+
[self.new(*ticket_attributes)]
|
24
13
|
end
|
25
14
|
|
26
15
|
# You don't need to define an initializer, this is only here to initialize dummy data
|
27
|
-
def initialize(*options)
|
16
|
+
def initialize(project_id, *options)
|
28
17
|
data = {:id => rand(1000), :status => ['lol', 'rofl', 'lmao', 'lamo', 'haha', 'heh'][rand(6)],
|
29
18
|
:priority => rand(10), :summary => 'Tickets ticket ticket ticket', :resolution => false,
|
30
19
|
:created_at => Time.now, :updated_at => Time.now, :description => 'Ticket ticket ticket ticket laughing',
|
31
|
-
:assignee => 'lol-man'}
|
20
|
+
:assignee => 'lol-man', :project_id => project_id}
|
32
21
|
@system = :dummy
|
33
22
|
super(data.merge(options.first || {}))
|
34
23
|
end
|
data/lib/ticketmaster/helper.rb
CHANGED
@@ -22,7 +22,7 @@ module TicketMaster::Provider
|
|
22
22
|
# Goes through all the things and returns results that match the options attributes hash
|
23
23
|
def search_by_attribute(things, options = {}, limit = 1000)
|
24
24
|
things.find_all do |thing|
|
25
|
-
options.
|
25
|
+
options.inject(true) do |memo, kv|
|
26
26
|
break unless memo
|
27
27
|
key, value = kv
|
28
28
|
begin
|
@@ -40,11 +40,11 @@ module TicketMaster::Provider
|
|
40
40
|
#
|
41
41
|
# ex: filter_string({:name => 'some value', :tags => ['abc', 'def']}) = "name:'some value' tag:abc tag:def"
|
42
42
|
def filter_string(filter = {}, array_join = nil)
|
43
|
-
filter.
|
43
|
+
filter.inject('') do |mem, kv|
|
44
44
|
key, value = kv
|
45
45
|
if value.is_a?(Array)
|
46
46
|
if !array_join.nil?
|
47
|
-
mem += value.
|
47
|
+
mem += value.inject('') { |m, v|
|
48
48
|
v = "\"#{v}\"" if v.to_s.include?(' ')
|
49
49
|
m+= "#{key}:#{v}"
|
50
50
|
}
|
@@ -44,6 +44,11 @@ module TicketMaster::Provider
|
|
44
44
|
easy_finder(@provider::Project, :all, options)
|
45
45
|
end
|
46
46
|
|
47
|
+
# Create a project same as project.create()
|
48
|
+
def project!(*options)
|
49
|
+
project.create(*options)
|
50
|
+
end
|
51
|
+
|
47
52
|
# Providers should try to define this method
|
48
53
|
#
|
49
54
|
# It returns the ticket class for this provider, so that there can be calls such as
|
data/lib/ticketmaster.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
%w{
|
2
2
|
rubygems
|
3
3
|
hashie
|
4
|
+
active_resource
|
4
5
|
}.each {|lib| require lib }
|
5
6
|
|
6
7
|
class TicketMaster
|
@@ -15,6 +16,7 @@ end
|
|
15
16
|
authenticator
|
16
17
|
provider
|
17
18
|
exception
|
19
|
+
dummy/dummy.rb
|
18
20
|
}.each {|lib| require File.dirname(__FILE__) + '/ticketmaster/' + lib }
|
19
21
|
|
20
22
|
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
# This can also act as an example test or test skeleton for your provider.
|
4
|
+
# Just replace the Dummy in @project_class and @ticket_class
|
5
|
+
# Also, remember to mock or stub any API calls
|
6
|
+
describe "Projects" do
|
7
|
+
before(:each) do
|
8
|
+
@ticketmaster = TicketMaster.new(:dummy, {})
|
9
|
+
@project_class = TicketMaster::Provider::Dummy::Project
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "with a connection to a provider" do
|
13
|
+
it "should return an array" do
|
14
|
+
@ticketmaster.projects.should be_an_instance_of Array
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return a project as first element" do
|
18
|
+
@ticketmaster.projects.first.should be_an_instance_of @project_class
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return a project as last element" do
|
22
|
+
@ticketmaster.projects.last.should be_an_instance_of @project_class
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return a Project by name from collection" do
|
26
|
+
@ticketmaster.project(:name => "Whack whack what?").should be_an_instance_of @project_class
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have a project description for first project" do
|
30
|
+
@ticketmaster.projects.first.description.should == "Mock!-ing Bird"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have a project name for first project" do
|
34
|
+
@ticketmaster.projects(:name => "Whack whack what?").first.name.should == "Whack whack what?"
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "when searching by ID" do
|
38
|
+
before do
|
39
|
+
@project = @ticketmaster.projects(555)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return an array" do
|
43
|
+
@project.should be_an_instance_of @project_class
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return Project with the correct ID" do
|
47
|
+
@project.id.should == 555
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "when searching with an array of IDs" do
|
52
|
+
before do
|
53
|
+
@projects = @ticketmaster.projects([555])
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should return an array" do
|
57
|
+
@projects.should be_an_instance_of Array
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should return a Project as first element" do
|
61
|
+
@projects.first.should be_an_instance_of @project_class
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should return Project with the correct ID" do
|
65
|
+
@projects.first.id.should == 555
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "when searching by hash" do
|
70
|
+
before do
|
71
|
+
@projects = @ticketmaster.projects(:id => 555)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should return an array" do
|
75
|
+
@projects.should be_an_instance_of Array
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should return a Project as first element" do
|
79
|
+
@projects.first.should be_an_instance_of @project_class
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should return Project with the correct ID" do
|
83
|
+
@projects.first.id.should == 555
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "for a specific project" do
|
89
|
+
it "should return the first project by default" do
|
90
|
+
@ticketmaster.project.should == @project_class
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "with no params" do
|
94
|
+
it "should return first Project" do
|
95
|
+
@ticketmaster.project.first.description.should == "Mock!-ing Bird"
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should return last project" do
|
99
|
+
@ticketmaster.project.last.description.should == "Mock!-ing Bird"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "when searching by hash" do
|
104
|
+
it "should return first Project" do
|
105
|
+
@ticketmaster.project.find(:first, :description => "Shocking Dirb").should be_an_instance_of @project_class
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should return first Project with correct description" do
|
109
|
+
@ticketmaster.project.find(:first, :description => "Shocking Dirb").description.should == "Shocking Dirb"
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should return last Project" do
|
113
|
+
@ticketmaster.project.find(:last, :description => "Shocking Dirb").should be_an_instance_of @project_class
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should return last Project with correct description" do
|
117
|
+
@ticketmaster.project.find(:last, :description => "Shocking Dirb").description.should == "Shocking Dirb"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe "declaring a new project" do
|
123
|
+
it "should return the correct class" do
|
124
|
+
@ticketmaster.project.new(default_info).should be_an_instance_of @project_class
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should have the correct name" do
|
128
|
+
@ticketmaster.project.new(default_info).name.should == "Tiket Name c"
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should be able to be saved" do
|
132
|
+
@ticketmaster.project.new(default_info).save.should be_true
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "creating a new project" do
|
137
|
+
it "should return the correct class" do
|
138
|
+
@ticketmaster.project.create(default_info).should be_an_instance_of @project_class
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should have the correct name" do
|
142
|
+
@ticketmaster.project.create(default_info).name.should == "Tiket Name c"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def default_info
|
147
|
+
{:id => 777, :name => "Tiket Name c", :description => "that c thinks the k is trying to steal it's identity"}
|
148
|
+
end
|
149
|
+
end
|
data/spec/rcov.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--exclude "lib/ticketmaster/dummy/*,spec/*,gems/*"
|
data/spec/ticket_spec.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
# This can also act as an example test or test skeleton for your provider.
|
4
|
+
# Just replace the Dummy in @project_class and @ticket_class
|
5
|
+
# Also, remember to mock or stub any API calls
|
6
|
+
describe "Tickets" do
|
7
|
+
before(:each) do
|
8
|
+
@ticketmaster = TicketMaster.new(:dummy, {})
|
9
|
+
@project_class = TicketMaster::Provider::Dummy::Project
|
10
|
+
@ticket_class = TicketMaster::Provider::Dummy::Ticket
|
11
|
+
@project = @ticketmaster.projects.first
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "for a Project" do
|
15
|
+
it "should return an array" do
|
16
|
+
@project.tickets.should be_an_instance_of Array
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return Ticket objects" do
|
20
|
+
@project.tickets.first.should be_an_instance_of @ticket_class
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "when searching wanting back all tickets that match the query" do
|
24
|
+
before do
|
25
|
+
@tickets = @project.tickets([999])
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should return an array" do
|
29
|
+
@tickets.should be_an_instance_of Array
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should return Ticket objects" do
|
33
|
+
@tickets.first.should be_an_instance_of @ticket_class
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return Tickets that match ID" do
|
37
|
+
@tickets.first.id.should == 999
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should return an array when passing query hash" do
|
41
|
+
@project.tickets(:id => 999).should be_an_instance_of Array
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "when searching wanting back the first ticket that matches the query" do
|
46
|
+
it "should return the first Ticket as a default" do
|
47
|
+
@project.ticket.should == TicketMaster::Provider::Dummy::Ticket
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "when querying using default ID query" do
|
51
|
+
it "should return a Ticket object" do
|
52
|
+
@project.ticket(888).should be_an_instance_of @ticket_class
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should only return Tickets with the correct ID" do
|
56
|
+
@project.ticket(888).id.should == 888
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "when querying using hash" do
|
61
|
+
it "should return a Ticket object" do
|
62
|
+
@project.ticket(:id => 888).should be_an_instance_of @ticket_class
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should only return Tickets with the correct ID" do
|
66
|
+
@project.ticket(:id => 888).id.should == 888
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should be able to do other ticket stuff"
|
73
|
+
|
74
|
+
end
|
data/spec/ticketmaster_spec.rb
CHANGED
@@ -5,9 +5,10 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
5
5
|
# Also, remember to mock or stub any API calls
|
6
6
|
describe "Ticketmaster" do
|
7
7
|
before(:each) do
|
8
|
-
@ticketmaster = TicketMaster.new(:dummy)
|
8
|
+
@ticketmaster = TicketMaster.new(:dummy, {})
|
9
9
|
@project_class = TicketMaster::Provider::Dummy::Project
|
10
10
|
@ticket_class = TicketMaster::Provider::Dummy::Ticket
|
11
|
+
@comment_class = TicketMaster::Provider::Dummy::Comment
|
11
12
|
end
|
12
13
|
|
13
14
|
# Essentially just a sanity check on the include since .new always returns the object's instance
|
@@ -15,44 +16,9 @@ describe "Ticketmaster" do
|
|
15
16
|
@ticketmaster.should be_an_instance_of TicketMaster
|
16
17
|
@ticketmaster.should be_a_kind_of TicketMaster::Provider::Dummy
|
17
18
|
end
|
18
|
-
|
19
|
-
it "should be able to load projects" do
|
20
|
-
@ticketmaster.projects.should be_an_instance_of Array
|
21
|
-
@ticketmaster.projects.first.should be_an_instance_of @project_class
|
22
|
-
@ticketmaster.projects.first.description.should == "Mock!-ing Bird"
|
23
|
-
@ticketmaster.projects(:id => 555).should be_an_instance_of Array
|
24
|
-
@ticketmaster.projects(:id => 555).first.should be_an_instance_of @project_class
|
25
|
-
@ticketmaster.projects(:id => 555).first.id.should == 555
|
26
|
-
|
27
|
-
@ticketmaster.project.should == @project_class
|
28
|
-
@ticketmaster.project(:name => "Whack whack what?").should be_an_instance_of @project_class
|
29
|
-
@ticketmaster.project(:name => "Whack whack what?").name.should == "Whack whack what?"
|
30
|
-
@ticketmaster.project.find(:first, :description => "Shocking Dirb").should be_an_instance_of @project_class
|
31
|
-
@ticketmaster.project.find(:first, :description => "Shocking Dirb").description.should == "Shocking Dirb"
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should be able to do project stuff" do
|
35
|
-
info = {:id => 777, :name => "Tiket Name c", :description => "that c thinks the k is trying to steal it's identity"}
|
36
|
-
@ticketmaster.project.create(info).should be_an_instance_of @project_class
|
37
|
-
@ticketmaster.project.new(info).should be_an_instance_of @project_class
|
38
|
-
@ticketmaster.project.create(info).id.should == 777
|
39
|
-
@ticketmaster.project.new(info).id.should == 777
|
40
19
|
|
41
|
-
|
42
|
-
end
|
20
|
+
it "should be able to load comments"
|
43
21
|
|
44
|
-
it "should be able to
|
45
|
-
|
46
|
-
project.tickets.should be_an_instance_of Array
|
47
|
-
project.tickets.first.should be_an_instance_of @ticket_class
|
48
|
-
project.tickets(:id => 999).should be_an_instance_of Array
|
49
|
-
project.tickets(:id => 999).first.should be_an_instance_of @ticket_class
|
50
|
-
project.tickets(:id => 999).first.id.should == 999
|
51
|
-
|
52
|
-
project.ticket.should == TicketMaster::Provider::Dummy::Ticket
|
53
|
-
project.ticket(:id => 888).should be_an_instance_of @ticket_class
|
54
|
-
project.ticket(:id => 888).id.should == 888
|
55
|
-
project.ticket.find(:first, :id => 888).should be_an_instance_of @ticket_class
|
56
|
-
project.ticket.find(:first, :id => 888).id.should == 888
|
57
|
-
end
|
22
|
+
it "should be able to do comment stuff"
|
23
|
+
|
58
24
|
end
|
data/ticketmaster.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ticketmaster}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Sirupsen", "deadprogrammer"]
|
12
|
-
s.date = %q{2010-07-
|
12
|
+
s.date = %q{2010-07-07}
|
13
13
|
s.default_executable = %q{ticket}
|
14
14
|
s.description = %q{Ticketmaster provides a universal API to trouble ticket and project management systems.}
|
15
15
|
s.email = %q{simon@hybridgroup.com}
|
@@ -45,6 +45,7 @@ Gem::Specification.new do |s|
|
|
45
45
|
"lib/ticketmaster/cli/init.rb",
|
46
46
|
"lib/ticketmaster/comment.rb",
|
47
47
|
"lib/ticketmaster/common.rb",
|
48
|
+
"lib/ticketmaster/dummy/comment.rb",
|
48
49
|
"lib/ticketmaster/dummy/dummy.rb",
|
49
50
|
"lib/ticketmaster/dummy/project.rb",
|
50
51
|
"lib/ticketmaster/dummy/ticket.rb",
|
@@ -53,13 +54,13 @@ Gem::Specification.new do |s|
|
|
53
54
|
"lib/ticketmaster/project.rb",
|
54
55
|
"lib/ticketmaster/provider.rb",
|
55
56
|
"lib/ticketmaster/ticket.rb",
|
57
|
+
"spec/project_spec.rb",
|
58
|
+
"spec/rcov.opts",
|
56
59
|
"spec/spec.opts",
|
57
60
|
"spec/spec_helper.rb",
|
61
|
+
"spec/ticket_spec.rb",
|
58
62
|
"spec/ticketmaster-cli_spec.rb",
|
59
63
|
"spec/ticketmaster_spec.rb",
|
60
|
-
"test/helper.rb",
|
61
|
-
"test/test_ticketmaster.rb",
|
62
|
-
"ticketmaster-0.3.2.gem",
|
63
64
|
"ticketmaster.gemspec"
|
64
65
|
]
|
65
66
|
s.homepage = %q{http://ticketrb.com}
|
@@ -68,11 +69,11 @@ Gem::Specification.new do |s|
|
|
68
69
|
s.rubygems_version = %q{1.3.7}
|
69
70
|
s.summary = %q{Ticketmaster provides a universal API to trouble ticket and project management systems.}
|
70
71
|
s.test_files = [
|
71
|
-
"spec/
|
72
|
+
"spec/project_spec.rb",
|
73
|
+
"spec/spec_helper.rb",
|
74
|
+
"spec/ticket_spec.rb",
|
72
75
|
"spec/ticketmaster-cli_spec.rb",
|
73
|
-
"spec/ticketmaster_spec.rb"
|
74
|
-
"test/helper.rb",
|
75
|
-
"test/test_ticketmaster.rb"
|
76
|
+
"spec/ticketmaster_spec.rb"
|
76
77
|
]
|
77
78
|
|
78
79
|
if s.respond_to? :specification_version then
|
@@ -81,13 +82,16 @@ Gem::Specification.new do |s|
|
|
81
82
|
|
82
83
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
83
84
|
s.add_runtime_dependency(%q<hashie>, [">= 0"])
|
85
|
+
s.add_runtime_dependency(%q<activeresource>, [">= 0"])
|
84
86
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
85
87
|
else
|
86
88
|
s.add_dependency(%q<hashie>, [">= 0"])
|
89
|
+
s.add_dependency(%q<activeresource>, [">= 0"])
|
87
90
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
88
91
|
end
|
89
92
|
else
|
90
93
|
s.add_dependency(%q<hashie>, [">= 0"])
|
94
|
+
s.add_dependency(%q<activeresource>, [">= 0"])
|
91
95
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
92
96
|
end
|
93
97
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ticketmaster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sirupsen
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-07-
|
19
|
+
date: 2010-07-07 00:00:00 -07:00
|
20
20
|
default_executable: ticket
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
type: :runtime
|
35
35
|
version_requirements: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
37
|
+
name: activeresource
|
38
38
|
prerelease: false
|
39
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
@@ -45,8 +45,22 @@ dependencies:
|
|
45
45
|
segments:
|
46
46
|
- 0
|
47
47
|
version: "0"
|
48
|
-
type: :
|
48
|
+
type: :runtime
|
49
49
|
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: shoulda
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
type: :development
|
63
|
+
version_requirements: *id003
|
50
64
|
description: Ticketmaster provides a universal API to trouble ticket and project management systems.
|
51
65
|
email: simon@hybridgroup.com
|
52
66
|
executables:
|
@@ -83,6 +97,7 @@ files:
|
|
83
97
|
- lib/ticketmaster/cli/init.rb
|
84
98
|
- lib/ticketmaster/comment.rb
|
85
99
|
- lib/ticketmaster/common.rb
|
100
|
+
- lib/ticketmaster/dummy/comment.rb
|
86
101
|
- lib/ticketmaster/dummy/dummy.rb
|
87
102
|
- lib/ticketmaster/dummy/project.rb
|
88
103
|
- lib/ticketmaster/dummy/ticket.rb
|
@@ -91,13 +106,13 @@ files:
|
|
91
106
|
- lib/ticketmaster/project.rb
|
92
107
|
- lib/ticketmaster/provider.rb
|
93
108
|
- lib/ticketmaster/ticket.rb
|
109
|
+
- spec/project_spec.rb
|
110
|
+
- spec/rcov.opts
|
94
111
|
- spec/spec.opts
|
95
112
|
- spec/spec_helper.rb
|
113
|
+
- spec/ticket_spec.rb
|
96
114
|
- spec/ticketmaster-cli_spec.rb
|
97
115
|
- spec/ticketmaster_spec.rb
|
98
|
-
- test/helper.rb
|
99
|
-
- test/test_ticketmaster.rb
|
100
|
-
- ticketmaster-0.3.2.gem
|
101
116
|
- ticketmaster.gemspec
|
102
117
|
has_rdoc: true
|
103
118
|
homepage: http://ticketrb.com
|
@@ -134,8 +149,8 @@ signing_key:
|
|
134
149
|
specification_version: 3
|
135
150
|
summary: Ticketmaster provides a universal API to trouble ticket and project management systems.
|
136
151
|
test_files:
|
152
|
+
- spec/project_spec.rb
|
137
153
|
- spec/spec_helper.rb
|
154
|
+
- spec/ticket_spec.rb
|
138
155
|
- spec/ticketmaster-cli_spec.rb
|
139
156
|
- spec/ticketmaster_spec.rb
|
140
|
-
- test/helper.rb
|
141
|
-
- test/test_ticketmaster.rb
|
data/test/helper.rb
DELETED
data/test/test_ticketmaster.rb
DELETED