ticketevolution-ruby 0.5.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.
Files changed (146) hide show
  1. data/.gitignore +8 -0
  2. data/.rdebugrc +1 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +6 -0
  5. data/Gemfile +7 -0
  6. data/LICENSE +23 -0
  7. data/README.markdown +237 -0
  8. data/Rakefile +124 -0
  9. data/examples/events.rb +64 -0
  10. data/lib/docs/endpoints.markdown +47 -0
  11. data/lib/docs/installation.markdown +5 -0
  12. data/lib/docs/introduction.markdown +16 -0
  13. data/lib/docs/objects.markdown +40 -0
  14. data/lib/ticket_evolution/account.rb +4 -0
  15. data/lib/ticket_evolution/accounts.rb +6 -0
  16. data/lib/ticket_evolution/address.rb +4 -0
  17. data/lib/ticket_evolution/brokerage.rb +4 -0
  18. data/lib/ticket_evolution/brokerages.rb +7 -0
  19. data/lib/ticket_evolution/categories.rb +7 -0
  20. data/lib/ticket_evolution/category.rb +4 -0
  21. data/lib/ticket_evolution/client.rb +4 -0
  22. data/lib/ticket_evolution/clients/addresses.rb +10 -0
  23. data/lib/ticket_evolution/clients/credit_cards.rb +8 -0
  24. data/lib/ticket_evolution/clients/email_addresses.rb +10 -0
  25. data/lib/ticket_evolution/clients/phone_numbers.rb +10 -0
  26. data/lib/ticket_evolution/clients.rb +8 -0
  27. data/lib/ticket_evolution/configuration.rb +4 -0
  28. data/lib/ticket_evolution/configurations.rb +6 -0
  29. data/lib/ticket_evolution/core/api_error.rb +11 -0
  30. data/lib/ticket_evolution/core/base.rb +12 -0
  31. data/lib/ticket_evolution/core/builder.rb +74 -0
  32. data/lib/ticket_evolution/core/collection.rb +32 -0
  33. data/lib/ticket_evolution/core/connection.rb +99 -0
  34. data/lib/ticket_evolution/core/datum.rb +7 -0
  35. data/lib/ticket_evolution/core/endpoint/request_handler.rb +46 -0
  36. data/lib/ticket_evolution/core/endpoint.rb +51 -0
  37. data/lib/ticket_evolution/core/model.rb +64 -0
  38. data/lib/ticket_evolution/core/models/samples.rb +8 -0
  39. data/lib/ticket_evolution/core/samples.rb +6 -0
  40. data/lib/ticket_evolution/core/singular_class.rb +7 -0
  41. data/lib/ticket_evolution/core/time.rb +19 -0
  42. data/lib/ticket_evolution/credit_card.rb +4 -0
  43. data/lib/ticket_evolution/email_address.rb +4 -0
  44. data/lib/ticket_evolution/errors/connection_not_found.rb +4 -0
  45. data/lib/ticket_evolution/errors/endpoint_configuration_error.rb +5 -0
  46. data/lib/ticket_evolution/errors/invalid_configuration.rb +4 -0
  47. data/lib/ticket_evolution/errors/method_unavailable_error.rb +4 -0
  48. data/lib/ticket_evolution/event.rb +4 -0
  49. data/lib/ticket_evolution/events.rb +7 -0
  50. data/lib/ticket_evolution/modules/create.rb +18 -0
  51. data/lib/ticket_evolution/modules/deleted.rb +13 -0
  52. data/lib/ticket_evolution/modules/list.rb +15 -0
  53. data/lib/ticket_evolution/modules/search.rb +13 -0
  54. data/lib/ticket_evolution/modules/show.rb +20 -0
  55. data/lib/ticket_evolution/modules/update.rb +24 -0
  56. data/lib/ticket_evolution/office.rb +4 -0
  57. data/lib/ticket_evolution/offices.rb +7 -0
  58. data/lib/ticket_evolution/order.rb +15 -0
  59. data/lib/ticket_evolution/orders.rb +30 -0
  60. data/lib/ticket_evolution/performer.rb +4 -0
  61. data/lib/ticket_evolution/performers.rb +8 -0
  62. data/lib/ticket_evolution/phone_number.rb +4 -0
  63. data/lib/ticket_evolution/quote.rb +4 -0
  64. data/lib/ticket_evolution/quotes.rb +7 -0
  65. data/lib/ticket_evolution/search.rb +22 -0
  66. data/lib/ticket_evolution/shipment.rb +4 -0
  67. data/lib/ticket_evolution/shipments.rb +8 -0
  68. data/lib/ticket_evolution/ticket_group.rb +4 -0
  69. data/lib/ticket_evolution/ticket_groups.rb +6 -0
  70. data/lib/ticket_evolution/user.rb +4 -0
  71. data/lib/ticket_evolution/users.rb +7 -0
  72. data/lib/ticket_evolution/venue.rb +4 -0
  73. data/lib/ticket_evolution/venues.rb +8 -0
  74. data/lib/ticket_evolution/version.rb +3 -0
  75. data/lib/ticket_evolution.rb +108 -0
  76. data/spec/fixtures/fake.rb +97 -0
  77. data/spec/fixtures/net/endpoints/accounts.yml +175 -0
  78. data/spec/fixtures/net/endpoints/brokerages.yml +257 -0
  79. data/spec/fixtures/net/endpoints/categories.yml +85 -0
  80. data/spec/fixtures/net/endpoints/clients.yml +243 -0
  81. data/spec/fixtures/net/endpoints/search.yml +93 -0
  82. data/spec/lib/ticket_evolution/account_spec.rb +7 -0
  83. data/spec/lib/ticket_evolution/accounts_spec.rb +45 -0
  84. data/spec/lib/ticket_evolution/address_spec.rb +7 -0
  85. data/spec/lib/ticket_evolution/brokerage_spec.rb +7 -0
  86. data/spec/lib/ticket_evolution/brokerages_spec.rb +50 -0
  87. data/spec/lib/ticket_evolution/categories_spec.rb +27 -0
  88. data/spec/lib/ticket_evolution/category_spec.rb +7 -0
  89. data/spec/lib/ticket_evolution/client_spec.rb +7 -0
  90. data/spec/lib/ticket_evolution/clients/addresses_spec.rb +13 -0
  91. data/spec/lib/ticket_evolution/clients/credit_cards_spec.rb +11 -0
  92. data/spec/lib/ticket_evolution/clients/email_addresses_spec.rb +13 -0
  93. data/spec/lib/ticket_evolution/clients/phone_numbers_spec.rb +13 -0
  94. data/spec/lib/ticket_evolution/clients_spec.rb +37 -0
  95. data/spec/lib/ticket_evolution/configuration_spec.rb +7 -0
  96. data/spec/lib/ticket_evolution/configurations_spec.rb +10 -0
  97. data/spec/lib/ticket_evolution/core/api_error_spec.rb +13 -0
  98. data/spec/lib/ticket_evolution/core/base_spec.rb +29 -0
  99. data/spec/lib/ticket_evolution/core/builder_spec.rb +95 -0
  100. data/spec/lib/ticket_evolution/core/collection_spec.rb +23 -0
  101. data/spec/lib/ticket_evolution/core/connection_spec.rb +220 -0
  102. data/spec/lib/ticket_evolution/core/datum_spec.rb +15 -0
  103. data/spec/lib/ticket_evolution/core/endpoint_spec.rb +12 -0
  104. data/spec/lib/ticket_evolution/core/model_spec.rb +167 -0
  105. data/spec/lib/ticket_evolution/core/time_spec.rb +28 -0
  106. data/spec/lib/ticket_evolution/credit_card_spec.rb +7 -0
  107. data/spec/lib/ticket_evolution/email_address_spec.rb +7 -0
  108. data/spec/lib/ticket_evolution/errors/connection_not_found_spec.rb +7 -0
  109. data/spec/lib/ticket_evolution/errors/endpoint_configuration_error_spec.rb +8 -0
  110. data/spec/lib/ticket_evolution/errors/invalid_configuration_spec.rb +8 -0
  111. data/spec/lib/ticket_evolution/errors/method_unavailable_error_spec.rb +7 -0
  112. data/spec/lib/ticket_evolution/event_spec.rb +7 -0
  113. data/spec/lib/ticket_evolution/events_spec.rb +11 -0
  114. data/spec/lib/ticket_evolution/office_spec.rb +7 -0
  115. data/spec/lib/ticket_evolution/offices_spec.rb +11 -0
  116. data/spec/lib/ticket_evolution/order_spec.rb +44 -0
  117. data/spec/lib/ticket_evolution/orders_spec.rb +123 -0
  118. data/spec/lib/ticket_evolution/performer_spec.rb +7 -0
  119. data/spec/lib/ticket_evolution/performers_spec.rb +12 -0
  120. data/spec/lib/ticket_evolution/phone_number_spec.rb +7 -0
  121. data/spec/lib/ticket_evolution/quote_spec.rb +7 -0
  122. data/spec/lib/ticket_evolution/quotes_spec.rb +11 -0
  123. data/spec/lib/ticket_evolution/search_spec.rb +31 -0
  124. data/spec/lib/ticket_evolution/shipment_spec.rb +7 -0
  125. data/spec/lib/ticket_evolution/shipments_spec.rb +13 -0
  126. data/spec/lib/ticket_evolution/ticket_group_spec.rb +7 -0
  127. data/spec/lib/ticket_evolution/ticket_groups_spec.rb +14 -0
  128. data/spec/lib/ticket_evolution/user_spec.rb +7 -0
  129. data/spec/lib/ticket_evolution/users_spec.rb +15 -0
  130. data/spec/lib/ticket_evolution/venue_spec.rb +7 -0
  131. data/spec/lib/ticket_evolution/venues_spec.rb +12 -0
  132. data/spec/lib/ticket_evolution_spec.rb +20 -0
  133. data/spec/shared_examples/endpoints/class.rb +241 -0
  134. data/spec/shared_examples/endpoints/create.rb +41 -0
  135. data/spec/shared_examples/endpoints/deleted.rb +41 -0
  136. data/spec/shared_examples/endpoints/list.rb +41 -0
  137. data/spec/shared_examples/endpoints/search.rb +42 -0
  138. data/spec/shared_examples/endpoints/show.rb +38 -0
  139. data/spec/shared_examples/endpoints/update.rb +59 -0
  140. data/spec/shared_examples/errors.rb +5 -0
  141. data/spec/shared_examples/models.rb +29 -0
  142. data/spec/spec_helper.rb +21 -0
  143. data/spec/support/connection.rb +10 -0
  144. data/spec/support/vcr.rb +12 -0
  145. data/ticketevolution-ruby.gemspec +33 -0
  146. metadata +384 -0
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Endpoint do
4
+ let(:klass) { TicketEvolution::Endpoint }
5
+ let(:single_klass) { TicketEvolution::Endpoint }
6
+
7
+ subject { klass }
8
+
9
+ its(:ancestors) { should include TicketEvolution::Base }
10
+
11
+ it_behaves_like "a ticket_evolution endpoint class"
12
+ end
@@ -0,0 +1,167 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Model do
4
+ let(:klass) { TicketEvolution::Model }
5
+ let(:sample_klass) { TicketEvolution::Models::Samples }
6
+ let(:instance) { klass.new({:id => 1, :connection => connection}) }
7
+ let(:connection) { Fake.connection }
8
+
9
+ subject { klass }
10
+
11
+ its(:ancestors) { should include TicketEvolution::Builder }
12
+
13
+ describe "#initialize" do
14
+ context "when it receives an instance of connection" do
15
+ subject { klass.new({:connection => connection}) }
16
+
17
+ it "should not error" do
18
+ expect { subject }.to_not raise_error
19
+ end
20
+
21
+ it "should not respond to #connection" do
22
+ subject.should_not respond_to :connection
23
+ end
24
+ end
25
+
26
+ context "when it does not receive an instance of connection" do
27
+ it "should raise a ConnectionNotFound error" do
28
+ message = "#{klass.name} must receive a TicketEvolution::Connection object on initialize"
29
+ expect { klass.new }.to raise_error TicketEvolution::ConnectionNotFound, message
30
+ end
31
+ end
32
+
33
+ context "when it detects a scope in the url" do
34
+ let(:instance) { klass.new({:connection => connection, 'url' => '/clients/2/addresses/1'}) }
35
+ let(:scope) { '/clients/2' }
36
+
37
+ it "should set @scope" do
38
+ instance.instance_eval{ @scope }.should == scope
39
+ end
40
+ end
41
+
42
+ context "when it does not detect a scope in the url" do
43
+ it "should not error" do
44
+ expect { klass.new({:connection => connection}) }.to_not raise_error
45
+ end
46
+ end
47
+ end
48
+
49
+ describe "#process_datum" do
50
+ context "when dealing with a hash" do
51
+ context "which has a :url key" do
52
+ let(:hash) do
53
+ {
54
+ "url" => "/brokerages/227",
55
+ "name" => "Night To Remember Tickets",
56
+ "id" => "227",
57
+ "abbreviation" => "Night to Remember"
58
+ }
59
+ end
60
+
61
+ it "should create an appropriate builder object" do
62
+ instance.instance_eval { @connection = Fake.connection }
63
+ instance.send(:process_datum, hash).should be_a TicketEvolution::Brokerage
64
+ end
65
+ end
66
+
67
+ context "which does not have a :url key" do
68
+ it "should instantiate a new TicketEvolution::Datum object" do
69
+ instance.send(:process_datum, {:one => 1}).should be_a TicketEvolution::Datum
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ describe "#plural_class_name" do
76
+ let(:plural_name) { klass.name.demodulize.pluralize.camelize }
77
+ context "when there is a scope" do
78
+ before { instance.instance_eval{ @scope = '/events/1' } }
79
+
80
+ it "should include the scoped endpoint name in the pluralized version of the current class" do
81
+ instance.plural_class_name.should == "TicketEvolution::Events::#{plural_name}"
82
+ end
83
+ end
84
+
85
+ context "when there is not a scope" do
86
+ it "should return the pluralized version of the current class" do
87
+ instance.plural_class_name.should == "TicketEvolution::#{plural_name}"
88
+ end
89
+ end
90
+ end
91
+
92
+ describe "#plural_class" do
93
+ let(:plural_class_name) { "TicketEvolution::Models" }
94
+ it "call #constantize on the result of #plural_class_name" do
95
+ instance.should_receive(:plural_class_name).and_return(plural_class_name)
96
+ plural_class_name.should_receive(:constantize)
97
+ instance.plural_class
98
+ end
99
+ end
100
+
101
+ describe "#scope" do
102
+ context "when @scope is set" do
103
+ before { instance.instance_eval{ @scope = '/events/1' } }
104
+ let(:scope_hash) { { :class => "TicketEvolution::Events", :id => 1 } }
105
+
106
+ it "should return and array with class and id specified" do
107
+ instance.scope.should == scope_hash
108
+ end
109
+ end
110
+
111
+ context "when @scope is not set" do
112
+ it "should return nil" do
113
+ instance.scope.should == nil
114
+ end
115
+ end
116
+ end
117
+
118
+ describe "#attributes" do
119
+ let(:params) { {"one" => 1, "two" => 2} }
120
+ let(:expected) { HashWithIndifferentAccess.new(params) }
121
+
122
+ it "should return the set attributes" do
123
+ klass.new(params.merge(:connection => connection)).attributes.should == expected
124
+ end
125
+ end
126
+
127
+ describe "#attributes=" do
128
+ let(:initial) { {"one" => :one, "three" => 3} }
129
+ let(:params) { {"one" => 1, "two" => 2} }
130
+ let(:expected) { HashWithIndifferentAccess.new(initial.merge(params)) }
131
+
132
+ it "should set the passed attributes" do
133
+ instance = klass.new(initial.merge(:connection => connection))
134
+ instance.attributes = params
135
+ instance.attributes.should == expected
136
+ end
137
+ end
138
+
139
+ describe "#method_missing" do
140
+ context "when the method ends in 's'" do
141
+ it "should attempt to find a class which matches the missing method, scoped to it's plural namespace" do
142
+ instance.plural_class.should_receive(:const_defined?).with(:NoObjects)
143
+ instance.no_objects
144
+ end
145
+ end
146
+
147
+ context "when the method does not end in 's'" do
148
+ it "should fall back on the default functionality" do
149
+ expect { instance.no_object=('') }.to_not raise_error
150
+ end
151
+ end
152
+
153
+ context "when the missing class is found" do
154
+ before { @endpoint = instance.plural_class.new({:id => instance.id, :parent => connection}) }
155
+
156
+ it "should instantiate a new instance of the requested endpoint, passing a new instance of it's endpoint class as parent" do
157
+ instance.plural_class.should_receive(:new).with({
158
+ :connection => connection,
159
+ :id => instance.id
160
+ }).and_return(@endpoint)
161
+ sample_klass.should_receive(:new).with({:parent => @endpoint})
162
+
163
+ instance.samples
164
+ end
165
+ end
166
+ end
167
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Time do
4
+ let(:klass) { TicketEvolution::Time }
5
+
6
+ subject { klass }
7
+
8
+ its(:ancestors) { should include ::Time }
9
+
10
+ describe "#parse" do
11
+ context "with a valid string" do
12
+ let(:str) { "2011-12-18T17:30:06Z" }
13
+ let(:expected) { klass.gm(2011,12,18,17,30,06) }
14
+
15
+ subject { klass.parse(str) }
16
+
17
+ it { should == expected }
18
+ end
19
+
20
+ describe "with an invalid string" do
21
+ let(:str) { "I've got a lovely bunch of coconuts." }
22
+
23
+ subject { klass.parse(str) }
24
+
25
+ it { should == str }
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::CreditCard do
4
+ subject { TicketEvolution::CreditCard }
5
+
6
+ it_behaves_like "a ticket_evolution model"
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::EmailAddress do
4
+ subject { TicketEvolution::EmailAddress }
5
+
6
+ it_behaves_like "a ticket_evolution model"
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::ConnectionNotFound do
4
+ subject { TicketEvolution::ConnectionNotFound }
5
+
6
+ it_behaves_like "a ticket_evolution error class"
7
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::EndpointConfigurationError do
4
+ subject { TicketEvolution::EndpointConfigurationError }
5
+
6
+ it_behaves_like "a ticket_evolution error class"
7
+ end
8
+
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::InvalidConfiguration do
4
+ subject { TicketEvolution::InvalidConfiguration }
5
+
6
+ it_behaves_like "a ticket_evolution error class"
7
+ end
8
+
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::MethodUnavailableError do
4
+ subject { TicketEvolution::MethodUnavailableError }
5
+
6
+ it_behaves_like "a ticket_evolution error class"
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Event do
4
+ subject { TicketEvolution::Event }
5
+
6
+ it_behaves_like "a ticket_evolution model"
7
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Events do
4
+ let(:klass) { TicketEvolution::Events }
5
+ let(:single_klass) { TicketEvolution::Event }
6
+
7
+ it_behaves_like 'a ticket_evolution endpoint class'
8
+ it_behaves_like 'a deleted endpoint'
9
+ it_behaves_like 'a list endpoint'
10
+ it_behaves_like 'a show endpoint'
11
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Office do
4
+ subject { TicketEvolution::Office }
5
+
6
+ it_behaves_like "a ticket_evolution model"
7
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Offices do
4
+ let(:klass) { TicketEvolution::Offices }
5
+ let(:single_klass) { TicketEvolution::Office }
6
+
7
+ it_behaves_like 'a ticket_evolution endpoint class'
8
+ it_behaves_like 'a list endpoint'
9
+ it_behaves_like 'a search endpoint'
10
+ it_behaves_like 'a show endpoint'
11
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Order do
4
+ subject { TicketEvolution::Order }
5
+ let(:klass) { TicketEvolution::Order }
6
+
7
+ it_behaves_like "a ticket_evolution model"
8
+
9
+ describe "custom methods" do
10
+ let(:connection) { Fake.connection }
11
+ let(:instance) { klass.new({:connection => connection, 'id' => 1}) }
12
+ let(:params) { {:test => "1... 2... 3..."} }
13
+ let(:plural_klass) { TicketEvolution::Orders }
14
+ let!(:plural_klass_instance) { plural_klass.new(:parent => connection) }
15
+
16
+ before do
17
+ plural_klass.should_receive(:new).with(:parent => connection).and_return(plural_klass_instance)
18
+ end
19
+
20
+ describe "#accept" do
21
+ it "should pass the request to TicketEvolution::Orders#accept_order" do
22
+ plural_klass_instance.should_receive(:accept_order).with(params).and_return(:dont_care)
23
+
24
+ instance.accept(params)
25
+ end
26
+ end
27
+
28
+ describe "#complete" do
29
+ it "should pass the request to TicketEvolution::Orders#complete_order" do
30
+ plural_klass_instance.should_receive(:complete_order).and_return(:dont_care)
31
+
32
+ instance.complete
33
+ end
34
+ end
35
+
36
+ describe "#reject" do
37
+ it "should pass the request to TicketEvolution::Orders#reject_order" do
38
+ plural_klass_instance.should_receive(:reject_order).with(params).and_return(:dont_care)
39
+
40
+ instance.reject(params)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,123 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Orders do
4
+ let(:klass) { TicketEvolution::Orders }
5
+ let(:single_klass) { TicketEvolution::Order }
6
+ let(:instance) { klass.new({:parent => Fake.connection}) }
7
+ let(:update_base) { {} }
8
+
9
+ it_behaves_like 'a ticket_evolution endpoint class'
10
+ it_behaves_like 'a create endpoint'
11
+ it_behaves_like 'a list endpoint'
12
+ it_behaves_like 'a show endpoint'
13
+ it_behaves_like 'an update endpoint'
14
+
15
+ it "should respond to create_brokerage_order" do
16
+ instance.should respond_to :create_brokerage_order
17
+ end
18
+
19
+ it "should respond to create_customer_order" do
20
+ instance.should respond_to :create_customer_order
21
+ end
22
+
23
+ describe "#accept_order" do
24
+ context "with an id" do
25
+ let(:instance) { klass.new({:parent => Fake.connection, :id => 1}) }
26
+
27
+ context "with params" do
28
+ let(:params) { {:reviewer_id => 1} }
29
+
30
+ it "should pass call request as a POST, passing params" do
31
+ instance.should_receive(:request).with(:POST, "/#{instance.id}/accept", params)
32
+
33
+ instance.accept_order(params)
34
+ end
35
+ end
36
+
37
+ context "without params" do
38
+ it "should pass call request as a POST, passing params" do
39
+ instance.should_receive(:request).with(:POST, "/#{instance.id}/accept", nil)
40
+
41
+ instance.accept_order
42
+ end
43
+ end
44
+ end
45
+
46
+ context "without an id" do
47
+ it "should raise an UnavailableMethodError if there is no id" do
48
+ message = "#{klass.to_s}#accept_order can only be called if there is an id present on this #{klass.to_s} instance"
49
+ expect { instance.accept_order }.to raise_error TicketEvolution::MethodUnavailableError, message
50
+ end
51
+ end
52
+ end
53
+
54
+ describe "#create_fulfillment_order" do
55
+ context "with params" do
56
+ let(:params) { {'some' => {'order' => 'info'}} }
57
+
58
+ it "should pass call request as a POST, passing params" do
59
+ instance.should_receive(:request).with(:POST, "/fulfillments", params)
60
+
61
+ instance.create_fulfillment_order(params)
62
+ end
63
+ end
64
+
65
+ context "without params" do
66
+ it "should pass call request as a POST, passing params" do
67
+ instance.should_receive(:request).with(:POST, "/fulfillments", nil)
68
+
69
+ instance.create_fulfillment_order
70
+ end
71
+ end
72
+ end
73
+
74
+ describe "#reject_order" do
75
+ context "with an id" do
76
+ let(:instance) { klass.new({:parent => Fake.connection, :id => 1}) }
77
+
78
+ context "with params" do
79
+ let(:params) { {:rejection_reason => "IT'S A TRAP!!", :reviewer_id => 1} }
80
+
81
+ it "should pass call request as a POST, passing params" do
82
+ instance.should_receive(:request).with(:POST, "/#{instance.id}/reject", params)
83
+
84
+ instance.reject_order(params)
85
+ end
86
+ end
87
+
88
+ context "without params" do
89
+ it "should pass call request as a POST, passing params" do
90
+ instance.should_receive(:request).with(:POST, "/#{instance.id}/reject", nil)
91
+
92
+ instance.reject_order
93
+ end
94
+ end
95
+ end
96
+
97
+ context "without an id" do
98
+ it "should raise an UnavailableMethodError if there is no id" do
99
+ message = "#{klass.to_s}#reject_order can only be called if there is an id present on this #{klass.to_s} instance"
100
+ expect { instance.reject_order }.to raise_error TicketEvolution::MethodUnavailableError, message
101
+ end
102
+ end
103
+ end
104
+
105
+ describe "#complete_order" do
106
+ context "with an id" do
107
+ let(:instance) { klass.new({:parent => Fake.connection, :id => 1}) }
108
+
109
+ it "should pass call request as a POST, passing params" do
110
+ instance.should_receive(:request).with(:POST, "/#{instance.id}/complete", nil)
111
+
112
+ instance.complete_order
113
+ end
114
+ end
115
+
116
+ context "without an id" do
117
+ it "should raise an UnavailableMethodError if there is no id" do
118
+ message = "#{klass.to_s}#complete_order can only be called if there is an id present on this #{klass.to_s} instance"
119
+ expect { instance.complete_order }.to raise_error TicketEvolution::MethodUnavailableError, message
120
+ end
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Performer do
4
+ subject { TicketEvolution::Performer }
5
+
6
+ it_behaves_like "a ticket_evolution model"
7
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Performers do
4
+ let(:klass) { TicketEvolution::Performers }
5
+ let(:single_klass) { TicketEvolution::Performer }
6
+
7
+ it_behaves_like 'a ticket_evolution endpoint class'
8
+ it_behaves_like 'a list endpoint'
9
+ it_behaves_like 'a search endpoint'
10
+ it_behaves_like 'a show endpoint'
11
+ it_behaves_like 'a deleted endpoint'
12
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::PhoneNumber do
4
+ subject { TicketEvolution::PhoneNumber }
5
+
6
+ it_behaves_like "a ticket_evolution model"
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Quote do
4
+ subject { TicketEvolution::Quote }
5
+
6
+ it_behaves_like "a ticket_evolution model"
7
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Quotes do
4
+ let(:klass) { TicketEvolution::Quotes }
5
+ let(:single_klass) { TicketEvolution::Quote }
6
+
7
+ it_behaves_like 'a ticket_evolution endpoint class'
8
+ it_behaves_like 'a list endpoint'
9
+ it_behaves_like 'a search endpoint'
10
+ it_behaves_like 'a show endpoint'
11
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Search do
4
+ let(:klass) { TicketEvolution::Search }
5
+ let(:single_klass) { TicketEvolution::Search }
6
+
7
+ it_behaves_like 'a ticket_evolution endpoint class'
8
+
9
+ context "integration tests" do
10
+ use_vcr_cassette "endpoints/search", :record => :new_episodes
11
+
12
+ it "returns a list of results" do
13
+ search_results = connection.search.list(:q => "rangers", :per_page => 5, :page => 1)
14
+
15
+ search_results.per_page.should == 5
16
+ search_results.current_page.should == 1
17
+ search_results.total_entries.should == 5
18
+
19
+ # Make sure that we have only and Venue and Performers
20
+ venues = search_results.select{|r| r.is_a?(TicketEvolution::Venue)}
21
+ venues.size.should > 0
22
+
23
+ performers = search_results.select{|r| r.is_a?(TicketEvolution::Performer)}
24
+ performers.size.should > 0
25
+
26
+ search_results.each do |result|
27
+ result.should be_a TicketEvolution::Model
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Shipment do
4
+ subject { TicketEvolution::Shipment }
5
+
6
+ it_behaves_like "a ticket_evolution model"
7
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Shipments do
4
+ let(:klass) { TicketEvolution::Shipments }
5
+ let(:single_klass) { TicketEvolution::Shipment }
6
+ let(:update_base) { {} }
7
+
8
+ it_behaves_like 'a ticket_evolution endpoint class'
9
+ it_behaves_like 'a list endpoint'
10
+ it_behaves_like 'a create endpoint'
11
+ it_behaves_like 'an update endpoint'
12
+ it_behaves_like 'a show endpoint'
13
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::TicketGroup do
4
+ subject { TicketEvolution::TicketGroup }
5
+
6
+ it_behaves_like "a ticket_evolution model"
7
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::TicketGroups do
4
+ let(:klass) { TicketEvolution::TicketGroups }
5
+ let(:single_klass) { TicketEvolution::TicketGroup }
6
+
7
+ it_behaves_like 'a ticket_evolution endpoint class'
8
+ it_behaves_like 'a list endpoint'
9
+ it_behaves_like 'a show endpoint'
10
+
11
+ it "should have a base path of /ticket_groups" do
12
+ klass.new({:parent => Fake.connection}).base_path.should == '/ticket_groups'
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::User do
4
+ subject { TicketEvolution::User }
5
+
6
+ it_behaves_like "a ticket_evolution model"
7
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Users do
4
+ let(:klass) { TicketEvolution::Users }
5
+ let(:single_klass) { TicketEvolution::User }
6
+
7
+ it_behaves_like 'a ticket_evolution endpoint class'
8
+ it_behaves_like 'a list endpoint'
9
+ it_behaves_like 'a search endpoint'
10
+ it_behaves_like 'a show endpoint'
11
+
12
+ it "should have a base path of /users" do
13
+ klass.new({:parent => Fake.connection}).base_path.should == '/users'
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Venue do
4
+ subject { TicketEvolution::Venue }
5
+
6
+ it_behaves_like "a ticket_evolution model"
7
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe TicketEvolution::Venues do
4
+ let(:klass) { TicketEvolution::Venues }
5
+ let(:single_klass) { TicketEvolution::Venue }
6
+
7
+ it_behaves_like 'a ticket_evolution endpoint class'
8
+ it_behaves_like 'a list endpoint'
9
+ it_behaves_like 'a search endpoint'
10
+ it_behaves_like 'a show endpoint'
11
+ it_behaves_like 'a deleted endpoint'
12
+ end