ticketevolution-ruby 0.6.6 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.minimum.versions.gemfile +1 -1
- data/README.markdown +2 -2
- data/Rakefile +2 -3
- data/lib/docs/objects.markdown +1 -1
- data/lib/faraday/response/verbose_logger.rb +34 -0
- data/lib/ticket_evolution/core/connection.rb +21 -23
- data/lib/ticket_evolution/core/endpoint/request_handler.rb +19 -9
- data/lib/ticket_evolution/core/model.rb +6 -4
- data/lib/ticket_evolution/modules/update.rb +18 -5
- data/lib/ticket_evolution/version.rb +1 -1
- data/lib/ticket_evolution.rb +3 -1
- data/spec/fixtures/fake.rb +1 -1
- data/spec/fixtures/net/core/connection.yml +43 -4
- data/spec/fixtures/net/endpoints/accounts.yml +44 -0
- data/spec/fixtures/net/endpoints/brokerages.yml +44 -0
- data/spec/fixtures/net/endpoints/clients/create.yml +287 -0
- data/spec/fixtures/net/endpoints/clients/update_fail.yml +958 -0
- data/spec/fixtures/net/endpoints/clients/update_success.yml +820 -0
- data/spec/fixtures/net/endpoints/clients.yml +585 -158
- data/spec/fixtures/net/endpoints/search.yml +49 -0
- data/spec/lib/ticket_evolution/accounts_spec.rb +1 -1
- data/spec/lib/ticket_evolution/client_spec.rb +37 -1
- data/spec/lib/ticket_evolution/clients_spec.rb +2 -2
- data/spec/lib/ticket_evolution/core/connection_spec.rb +23 -15
- data/spec/lib/ticket_evolution/search_spec.rb +1 -10
- data/spec/shared_examples/endpoints/class.rb +19 -26
- data/spec/shared_examples/endpoints/update.rb +51 -12
- data/spec/support/connection.rb +2 -0
- data/ticketevolution-ruby.gemspec +2 -2
- metadata +36 -26
@@ -91,3 +91,52 @@
|
|
91
91
|
Rangers","id":"15544"},{"_score":1.0,"upcoming_events":{"last":"2012-09-30T13:00:00Z","first":"2012-04-06T13:00:00Z"},"location":"Arlington,
|
92
92
|
TX","url":"/venues/1776","_type":"Venue","name":"Rangers Ballpark in Arlington","id":"1776"}],"per_page":5,"total_entries":5}'
|
93
93
|
http_version: '1.1'
|
94
|
+
- !ruby/struct:VCR::HTTPInteraction
|
95
|
+
request: !ruby/struct:VCR::Request
|
96
|
+
method: :get
|
97
|
+
uri: https://api.sandbox.ticketevolution.com:443/search?page=1&per_page=5&q=play
|
98
|
+
body: !!null
|
99
|
+
headers:
|
100
|
+
x-signature:
|
101
|
+
- lPr828LG8Mp8hevhwMIsxCs8shevGTSLw/5Y8cABLtU=
|
102
|
+
x-token:
|
103
|
+
- b2b5a7a33b1a78896ed1b53d81c5c9cc
|
104
|
+
accept:
|
105
|
+
- application/vnd.ticketevolution.api+json; version=8
|
106
|
+
accept-encoding:
|
107
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
108
|
+
response: !ruby/struct:VCR::Response
|
109
|
+
status: !ruby/struct:VCR::ResponseStatus
|
110
|
+
code: 200
|
111
|
+
message: OK
|
112
|
+
headers:
|
113
|
+
content-type:
|
114
|
+
- application/vnd.ticketevolution.api+json; version=8; charset=utf-8
|
115
|
+
transfer-encoding:
|
116
|
+
- chunked
|
117
|
+
connection:
|
118
|
+
- keep-alive
|
119
|
+
status:
|
120
|
+
- '200'
|
121
|
+
x-powered-by:
|
122
|
+
- Phusion Passenger (mod_rails/mod_rack) 3.0.11
|
123
|
+
etag:
|
124
|
+
- ! '"86734a4cc711fc99c4d796772409e496"'
|
125
|
+
x-ua-compatible:
|
126
|
+
- IE=Edge,chrome=1
|
127
|
+
x-runtime:
|
128
|
+
- '0.783169'
|
129
|
+
cache-control:
|
130
|
+
- max-age=0, private, must-revalidate
|
131
|
+
strict-transport-security:
|
132
|
+
- max-age=31536000
|
133
|
+
server:
|
134
|
+
- nginx/1.0.11 + Phusion Passenger 3.0.11 (mod_rails/mod_rack)
|
135
|
+
body: ! '{"current_page":1,"per_page":5,"total_entries":17,"results":[{"_type":"Performer","_score":1.0,"upcoming_events":{"last":"2012-05-13T07:00:00Z","first":"2012-05-07T06:00:00Z"},"name":"The
|
136
|
+
Players Championship","id":"15088","url":"/performers/15088"},{"_type":"Performer","_score":1.0,"upcoming_events":{"last":"2012-04-01T15:00:00Z","first":"2012-03-23T19:30:00Z"},"name":"In
|
137
|
+
the Next Room [or the Vibrator Play]","id":"18830","url":"/performers/18830"},{"_type":"Performer","_score":1.0,"upcoming_events":{"last":"2012-03-01T19:30:00Z","first":"2012-02-24T20:00:00Z"},"name":"Playing
|
138
|
+
for Change","id":"8942","url":"/performers/8942"},{"_type":"Performer","_score":1.0,"upcoming_events":{"last":"2012-02-26T12:05:00Z","first":"2012-02-22T09:00:00Z"},"name":"Accenture
|
139
|
+
Match Play Championship","id":"14994","url":"/performers/14994"},{"location":"Fort
|
140
|
+
Lauderdale, FL","_type":"Venue","_score":1.0,"upcoming_events":{"last":"2012-03-23T20:00:00Z","first":"2012-03-23T20:00:00Z"},"name":"Parker
|
141
|
+
Playhouse","id":"1200","url":"/venues/1200"}]}'
|
142
|
+
http_version: '1.1'
|
@@ -18,7 +18,7 @@ describe TicketEvolution::Accounts do
|
|
18
18
|
account.url.should == "/accounts/#{id}"
|
19
19
|
account.currency.should == "USD"
|
20
20
|
account.updated_at.should_not be_nil
|
21
|
-
account.balance.should == "
|
21
|
+
account.balance.should == "8583.71"
|
22
22
|
account.id.should == id.to_s
|
23
23
|
|
24
24
|
account.client.should == TicketEvolution::Client.new({
|
@@ -7,7 +7,7 @@ describe TicketEvolution::Client do
|
|
7
7
|
describe "when calling a nested endpoint method" do
|
8
8
|
use_vcr_cassette "endpoints/clients", :record => :new_episodes
|
9
9
|
|
10
|
-
let(:client) { TicketEvolution::Clients.new(:parent => connection).list.
|
10
|
+
let(:client) { TicketEvolution::Clients.new(:parent => connection).list.first }
|
11
11
|
|
12
12
|
it "should pass the request to the appropriate endpoint and get back an appropriate response" do
|
13
13
|
collection = client.addresses.list
|
@@ -18,4 +18,40 @@ describe TicketEvolution::Client do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it_behaves_like "a ticket_evolution model"
|
21
|
+
|
22
|
+
context "#update_attributes" do
|
23
|
+
let(:client) { connection.clients.create(:name => "foo") }
|
24
|
+
let(:initial_client_id) { client.id }
|
25
|
+
|
26
|
+
context "on success" do
|
27
|
+
use_vcr_cassette "endpoints/clients/update_success", :record => :new_episodes, :match_requests_on => [:method, :uri, :body]
|
28
|
+
before { client }
|
29
|
+
|
30
|
+
it "updates the attributes of the instance" do
|
31
|
+
client_instance = client.update_attributes(:name => "bar")
|
32
|
+
client_instance.should be_an_instance_of TicketEvolution::Client
|
33
|
+
client.id.should == initial_client_id
|
34
|
+
client.name.should == "bar"
|
35
|
+
|
36
|
+
retrieved_client = connection.clients.find(initial_client_id)
|
37
|
+
retrieved_client.name.should == "bar"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "on error" do
|
42
|
+
use_vcr_cassette "endpoints/clients/update_fail", :record => :new_episodes, :match_requests_on => [:method, :uri, :body]
|
43
|
+
before { client }
|
44
|
+
|
45
|
+
it "doesn't update the attributes of the instance" do
|
46
|
+
ret = client.update_attributes(:name => "")
|
47
|
+
client.id.should == initial_client_id
|
48
|
+
client.name.should == "foo"
|
49
|
+
ret.should be_an_instance_of TicketEvolution::ApiError
|
50
|
+
ret.code.should == 422
|
51
|
+
|
52
|
+
retrieved_client = connection.clients.find(initial_client_id)
|
53
|
+
retrieved_client.name.should == "foo"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
21
57
|
end
|
@@ -12,9 +12,9 @@ describe TicketEvolution::Clients do
|
|
12
12
|
it_behaves_like 'an update endpoint'
|
13
13
|
|
14
14
|
describe "integrations" do
|
15
|
-
use_vcr_cassette "endpoints/clients", :record => :new_episodes, :match_requests_on => [:method, :uri, :body]
|
16
|
-
|
17
15
|
context "#create" do
|
16
|
+
use_vcr_cassette "endpoints/clients/create", :record => :new_episodes, :match_requests_on => [:method, :uri, :body]
|
17
|
+
|
18
18
|
it "returns validation errors" do
|
19
19
|
client = connection.clients.create(:name => "")
|
20
20
|
client.should be_an_instance_of TicketEvolution::ApiError
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'logger'
|
2
3
|
|
3
4
|
describe TicketEvolution::Connection do
|
4
5
|
let(:klass) { TicketEvolution::Connection }
|
@@ -40,6 +41,14 @@ describe TicketEvolution::Connection do
|
|
40
41
|
it { should be_a Fixnum }
|
41
42
|
end
|
42
43
|
|
44
|
+
describe ".adapter" do
|
45
|
+
subject { klass.adapter }
|
46
|
+
|
47
|
+
it "should be an available Faraday adapter" do
|
48
|
+
Faraday::Adapter.constants.collect{|a| a.to_s.underscore.to_sym}.should include subject
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
43
52
|
describe "#initialize" do
|
44
53
|
let(:expected_options) { klass.expected_options }
|
45
54
|
|
@@ -55,20 +64,19 @@ describe TicketEvolution::Connection do
|
|
55
64
|
context "if passed" do
|
56
65
|
let(:options) { valid_options.merge(:ssl_verify => false) }
|
57
66
|
|
58
|
-
it "sets the
|
67
|
+
it "sets the request object to ssl verify false" do
|
59
68
|
connection = klass.new(options)
|
60
|
-
|
61
|
-
|
62
|
-
easy.ssl_verify_peer?.should be_false
|
69
|
+
request = connection.build_request(:GET, '/')
|
70
|
+
request.ssl[:verify].should be_false
|
63
71
|
end
|
64
72
|
end
|
65
73
|
|
66
74
|
context "if not passed" do
|
67
|
-
it "
|
75
|
+
it "sets the request object to ssl verify true" do
|
76
|
+
pending "sandbox ssl being fixed"
|
68
77
|
connection = klass.new(valid_options)
|
69
|
-
|
70
|
-
|
71
|
-
easy.ssl_verify_peer?.should be_true
|
78
|
+
request = connection.build_request(:GET, '/')
|
79
|
+
request.ssl[:verify].should be_true
|
72
80
|
end
|
73
81
|
end
|
74
82
|
end
|
@@ -112,14 +120,15 @@ describe TicketEvolution::Connection do
|
|
112
120
|
context "with logger object is set" do
|
113
121
|
use_vcr_cassette "core/connection", :record => :all
|
114
122
|
|
115
|
-
let(:
|
123
|
+
let(:target) { StringIO.new }
|
124
|
+
let(:logger) { Logger.new(target) }
|
116
125
|
let(:instance) { klass.new(valid_options.merge({:logger => logger})) }
|
117
126
|
|
118
127
|
it "should add the requests and responses to the object" do
|
119
128
|
expect {
|
120
129
|
req = instance.build_request(:GET, '/', {})
|
121
|
-
req.
|
122
|
-
}.to change(
|
130
|
+
req.get
|
131
|
+
}.to change(target, :size).by_at_least(1)
|
123
132
|
end
|
124
133
|
end
|
125
134
|
end
|
@@ -171,7 +180,7 @@ describe TicketEvolution::Connection do
|
|
171
180
|
subject { klass.new(valid_options.merge({:version => 9})) }
|
172
181
|
|
173
182
|
it "should include the version" do
|
174
|
-
subject.uri(path).should == "#{subject.url}/
|
183
|
+
subject.uri(path).should == "#{subject.url}/v9#{path}"
|
175
184
|
end
|
176
185
|
end
|
177
186
|
end
|
@@ -260,8 +269,7 @@ describe TicketEvolution::Connection do
|
|
260
269
|
|
261
270
|
subject { klass.new(valid_options).build_request(:GET, '/test', params) }
|
262
271
|
|
263
|
-
it { should be_a
|
264
|
-
its(:url) { should == url }
|
272
|
+
it { should be_a Faraday::Connection }
|
265
273
|
|
266
274
|
context "api version 8" do
|
267
275
|
let(:headers) do
|
@@ -279,7 +287,7 @@ describe TicketEvolution::Connection do
|
|
279
287
|
context "api version 9 or above" do
|
280
288
|
let(:headers) do
|
281
289
|
{
|
282
|
-
"X-Signature" => "
|
290
|
+
"X-Signature" => "YbwEmJL9P0hvpplEr2q2iL4Mpz+KevHUOjzgYh0ewh4=",
|
283
291
|
"X-Token" => valid_options[:token]
|
284
292
|
}
|
285
293
|
end
|
@@ -10,19 +10,10 @@ describe TicketEvolution::Search do
|
|
10
10
|
use_vcr_cassette "endpoints/search", :record => :new_episodes
|
11
11
|
|
12
12
|
it "returns a list of results" do
|
13
|
-
search_results = connection.search.list(:q => "
|
13
|
+
search_results = connection.search.list(:q => "play", :per_page => 5, :page => 1)
|
14
14
|
|
15
15
|
search_results.per_page.should == 5
|
16
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
17
|
search_results.each do |result|
|
27
18
|
result.should be_a TicketEvolution::Model
|
28
19
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
shared_examples_for "a ticket_evolution endpoint class" do
|
4
4
|
let(:connection) { TicketEvolution::Connection.new({:token => Fake.token, :secret => Fake.secret}) }
|
5
5
|
let(:sample_parent) { TicketEvolution::Samples.new }
|
6
|
-
let(:
|
6
|
+
let(:faraday) { double(:faraday, :get => nil, :post => nil, :put => nil, :delete => nil) }
|
7
7
|
let(:instance) { klass.new({:parent => connection}) }
|
8
8
|
let(:path) { '/search' }
|
9
9
|
let(:full_path) { "#{instance.base_path}#{path}" }
|
@@ -132,7 +132,7 @@ shared_examples_for "a ticket_evolution endpoint class" do
|
|
132
132
|
|
133
133
|
[:GET, :POST, :PUT, :DELETE].each do |method|
|
134
134
|
it "should accept an http '#{method}' method, a url path for the call and a list of parameters as a hash and pass them to connection" do
|
135
|
-
connection.should_receive(:build_request).with(method, full_path, params).and_return(
|
135
|
+
connection.should_receive(:build_request).with(method, full_path, params).and_return(faraday)
|
136
136
|
|
137
137
|
instance.build_request(method, path, params)
|
138
138
|
end
|
@@ -142,7 +142,7 @@ shared_examples_for "a ticket_evolution endpoint class" do
|
|
142
142
|
context "without params" do
|
143
143
|
[:GET, :POST, :PUT, :DELETE].each do |method|
|
144
144
|
it "should accept an http '#{method}' method and a url path for the call and pass them to connection" do
|
145
|
-
connection.should_receive(:build_request).with(method, full_path, nil).and_return(
|
145
|
+
connection.should_receive(:build_request).with(method, full_path, nil).and_return(faraday)
|
146
146
|
|
147
147
|
instance.build_request(method, path)
|
148
148
|
end
|
@@ -152,7 +152,7 @@ shared_examples_for "a ticket_evolution endpoint class" do
|
|
152
152
|
context "with build_path set to false" do
|
153
153
|
[:GET, :POST, :PUT, :DELETE].each do |method|
|
154
154
|
it "should not include the base_path when it calls connection#build_request" do
|
155
|
-
connection.should_receive(:build_request).with(method, path, nil).and_return(
|
155
|
+
connection.should_receive(:build_request).with(method, path, nil).and_return(faraday)
|
156
156
|
|
157
157
|
instance.build_request(method, path, nil, false)
|
158
158
|
end
|
@@ -175,13 +175,9 @@ shared_examples_for "a ticket_evolution endpoint class" do
|
|
175
175
|
let(:response) { Fake.response }
|
176
176
|
let(:handler) { Fake.send(:method, :response_handler) }
|
177
177
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
it "calls http on the return Curl object with the method for the request" do
|
182
|
-
connection.should_receive(:build_request).and_return(curl)
|
178
|
+
it "calls http on the return faraday object with the method for the request" do
|
179
|
+
connection.should_receive(:build_request).and_return(faraday)
|
183
180
|
instance.should_receive(:naturalize_response).and_return(response)
|
184
|
-
curl.should_receive(:http).with(method)
|
185
181
|
|
186
182
|
instance.request(method, path, nil, &handler).should == Fake.response_handler(true)
|
187
183
|
end
|
@@ -190,9 +186,8 @@ shared_examples_for "a ticket_evolution endpoint class" do
|
|
190
186
|
let(:response) { Fake.error_response }
|
191
187
|
|
192
188
|
before do
|
193
|
-
connection.should_receive(:build_request).and_return(
|
189
|
+
connection.should_receive(:build_request).and_return(faraday)
|
194
190
|
instance.should_receive(:naturalize_response).and_return(response)
|
195
|
-
curl.should_receive(:http)
|
196
191
|
end
|
197
192
|
|
198
193
|
it "should return an instance of TicketEvolution::ApiError" do
|
@@ -204,9 +199,8 @@ shared_examples_for "a ticket_evolution endpoint class" do
|
|
204
199
|
let(:response) { Fake.response }
|
205
200
|
|
206
201
|
before do
|
207
|
-
connection.should_receive(:build_request).and_return(
|
202
|
+
connection.should_receive(:build_request).and_return(faraday)
|
208
203
|
instance.should_receive(:naturalize_response).and_return(response)
|
209
|
-
curl.should_receive(:http)
|
210
204
|
end
|
211
205
|
|
212
206
|
it "should pass the response object to #build_object" do
|
@@ -216,17 +210,16 @@ shared_examples_for "a ticket_evolution endpoint class" do
|
|
216
210
|
|
217
211
|
context "when there is a redirect response" do
|
218
212
|
let(:response) { Fake.redirect_response }
|
213
|
+
let(:faraday_response) { double(:dummy_response) }
|
219
214
|
let(:redirect_path) { '/something_else/1'}
|
220
|
-
let(:
|
215
|
+
let(:second_faraday) { double(:faraday, :get => nil, :post => nil, :put => nil, :delete => nil) }
|
221
216
|
let(:second_response) { Fake.response }
|
222
217
|
|
223
218
|
before do
|
224
|
-
|
225
|
-
|
226
|
-
instance.should_receive(:
|
227
|
-
|
228
|
-
instance.connection.should_receive(:build_request).with(:GET, redirect_path, nil).and_return(second_curl)
|
229
|
-
instance.should_receive(:naturalize_response).with(second_curl).and_return(second_response)
|
219
|
+
connection.should_receive(:build_request).with(:GET, instance.base_path, nil).and_return(faraday)
|
220
|
+
instance.should_receive(:naturalize_response).and_return(response)
|
221
|
+
instance.connection.should_receive(:build_request).with(:GET, redirect_path, nil).and_return(second_faraday)
|
222
|
+
instance.should_receive(:naturalize_response).and_return(second_response)
|
230
223
|
end
|
231
224
|
|
232
225
|
it "should follow the redirect path" do
|
@@ -241,17 +234,17 @@ shared_examples_for "a ticket_evolution endpoint class" do
|
|
241
234
|
let(:full_path) { "#{instance.base_path}#{path}" }
|
242
235
|
let(:response_code) { 200 }
|
243
236
|
let(:response) { mock(:response, {
|
244
|
-
:
|
245
|
-
:
|
246
|
-
:
|
237
|
+
:headers => {},
|
238
|
+
:status => response_code,
|
239
|
+
:body => body_str
|
247
240
|
}) }
|
248
241
|
|
249
242
|
context "with a valid body" do
|
250
243
|
subject { instance.naturalize_response response }
|
251
244
|
let(:body_str) { "{\"test\": \"hello\"}" }
|
252
245
|
|
253
|
-
its(:header) { should == response.
|
254
|
-
its(:body) { should == MultiJson.decode(response.
|
246
|
+
its(:header) { should == response.headers }
|
247
|
+
its(:body) { should == MultiJson.decode(response.body).merge({:connection => connection}) }
|
255
248
|
|
256
249
|
TicketEvolution::Endpoint::RequestHandler::CODES.each do |code, value|
|
257
250
|
context "with response code #{code}" do
|
@@ -12,7 +12,7 @@ shared_examples_for "an update endpoint" do
|
|
12
12
|
let(:params) { {:name => "Bob"} }
|
13
13
|
|
14
14
|
it "should pass call request as a PUT, passing params" do
|
15
|
-
instance.should_receive(:request).with(:PUT,
|
15
|
+
instance.should_receive(:request).with(:PUT, nil, params)
|
16
16
|
|
17
17
|
instance.update(params)
|
18
18
|
end
|
@@ -20,7 +20,7 @@ shared_examples_for "an update endpoint" do
|
|
20
20
|
|
21
21
|
context "without params" do
|
22
22
|
it "should pass call request as a PUT, passing params" do
|
23
|
-
instance.should_receive(:request).with(:PUT,
|
23
|
+
instance.should_receive(:request).with(:PUT, nil, nil)
|
24
24
|
|
25
25
|
instance.update
|
26
26
|
end
|
@@ -39,21 +39,60 @@ shared_examples_for "an update endpoint" do
|
|
39
39
|
let(:model_klass) { instance.singular_class }
|
40
40
|
let(:model_instance) { model_klass.new(attributes.merge({:connection => connection})) }
|
41
41
|
let(:attributes) { HashWithIndifferentAccess.new(update_base.merge({:one => 1, :two => "two", :three => nil, :id => 1})) }
|
42
|
-
let(:stored_attributes) { attributes.delete_if{|k, v| k == 'id'} }
|
43
|
-
let(:updated_attributes) { HashWithIndifferentAccess.new({:one => "one", :three => 3}) }
|
44
|
-
let(:merged_attributes) { attributes.merge(updated_attributes) }
|
45
42
|
|
46
|
-
it "should set an update_attributes method on it's corresponding TE:Model class
|
43
|
+
it "should set an update_attributes method on it's corresponding TE:Model class" do
|
47
44
|
model_instance.should respond_to :update_attributes
|
48
|
-
klass.any_instance.should_receive(:update).with(updated_attributes).and_return(nil)
|
49
|
-
model_instance.update_attributes(updated_attributes)
|
50
|
-
model_instance.attributes.should == merged_attributes
|
51
45
|
end
|
52
46
|
|
53
|
-
it "should set a save method on it's corresponding TE:Model class
|
47
|
+
it "should set a save method on it's corresponding TE:Model class" do
|
54
48
|
model_instance.should respond_to :save
|
55
|
-
|
56
|
-
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "it's corresponding model object" do
|
53
|
+
let(:singular_klass) { Class.new{extend TicketEvolution::SingularClass}.singular_class(klass.name) }
|
54
|
+
|
55
|
+
describe "#update_attributes" do
|
56
|
+
let(:instance) { singular_klass.new(update_base.merge({
|
57
|
+
:connection => connection,
|
58
|
+
:id => 1,
|
59
|
+
:first_name => "John",
|
60
|
+
:last_name => "Doe"
|
61
|
+
})) }
|
62
|
+
let(:params) { {:first_name => "Bob"} }
|
63
|
+
let(:expected) do
|
64
|
+
data = instance.attributes.merge(params)
|
65
|
+
data.delete(:id)
|
66
|
+
data
|
67
|
+
end
|
68
|
+
let(:response) { mock(:response, :attributes => params) }
|
69
|
+
|
70
|
+
it "should pass call request as a PUT, passing params" do
|
71
|
+
klass.any_instance.should_receive(:request).with(:PUT, nil, expected).and_return(response)
|
72
|
+
|
73
|
+
instance.update_attributes(params)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#save" do
|
78
|
+
let(:instance) { singular_klass.new(update_base.merge({
|
79
|
+
:connection => connection,
|
80
|
+
:id => 1,
|
81
|
+
:first_name => "John",
|
82
|
+
:last_name => "Doe"
|
83
|
+
})) }
|
84
|
+
let(:expected) do
|
85
|
+
data = instance.attributes
|
86
|
+
data.delete(:id)
|
87
|
+
data
|
88
|
+
end
|
89
|
+
let(:response) { mock(:response, :attributes => {}) }
|
90
|
+
|
91
|
+
it "should pass call request as a PUT, passing params" do
|
92
|
+
klass.any_instance.should_receive(:request).with(:PUT, nil, expected).and_return(response)
|
93
|
+
|
94
|
+
instance.save
|
95
|
+
end
|
57
96
|
end
|
58
97
|
end
|
59
98
|
end
|
data/spec/support/connection.rb
CHANGED
@@ -14,14 +14,14 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.required_rubygems_version = '>= 1.3.5'
|
15
15
|
|
16
16
|
s.add_dependency 'activesupport', '>= 3.0.0'
|
17
|
-
s.add_dependency '
|
17
|
+
s.add_dependency 'faraday', '>= 0.7.3'
|
18
18
|
s.add_dependency 'yajl-ruby', '>= 0.7.7'
|
19
19
|
s.add_dependency 'multi_json', '>= 0.0.4'
|
20
20
|
s.add_dependency 'nokogiri', '>= 1.4.3'
|
21
21
|
|
22
22
|
s.add_development_dependency 'rspec', '>= 2.7.1'
|
23
23
|
s.add_development_dependency 'vcr'
|
24
|
-
s.add_development_dependency 'webmock'
|
24
|
+
s.add_development_dependency 'webmock', '>= 1.7.0', '< 1.8.0'
|
25
25
|
s.add_development_dependency 'awesome_print'
|
26
26
|
s.add_development_dependency 'rake'
|
27
27
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ticketevolution-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-22 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70237160533160 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,21 +21,21 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70237160533160
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
requirement: &
|
26
|
+
name: faraday
|
27
|
+
requirement: &70237160532300 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.7.
|
32
|
+
version: 0.7.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70237160532300
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: yajl-ruby
|
38
|
-
requirement: &
|
38
|
+
requirement: &70237160531400 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.7.7
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70237160531400
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: multi_json
|
49
|
-
requirement: &
|
49
|
+
requirement: &70237160554020 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.0.4
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70237160554020
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: nokogiri
|
60
|
-
requirement: &
|
60
|
+
requirement: &70237160558360 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.4.3
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70237160558360
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &70237160562360 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 2.7.1
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70237160562360
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: vcr
|
82
|
-
requirement: &
|
82
|
+
requirement: &70237160565180 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,21 +87,24 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70237160565180
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: webmock
|
93
|
-
requirement: &
|
93
|
+
requirement: &70237164781380 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
98
|
+
version: 1.7.0
|
99
|
+
- - <
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.8.0
|
99
102
|
type: :development
|
100
103
|
prerelease: false
|
101
|
-
version_requirements: *
|
104
|
+
version_requirements: *70237164781380
|
102
105
|
- !ruby/object:Gem::Dependency
|
103
106
|
name: awesome_print
|
104
|
-
requirement: &
|
107
|
+
requirement: &70237165260260 !ruby/object:Gem::Requirement
|
105
108
|
none: false
|
106
109
|
requirements:
|
107
110
|
- - ! '>='
|
@@ -109,10 +112,10 @@ dependencies:
|
|
109
112
|
version: '0'
|
110
113
|
type: :development
|
111
114
|
prerelease: false
|
112
|
-
version_requirements: *
|
115
|
+
version_requirements: *70237165260260
|
113
116
|
- !ruby/object:Gem::Dependency
|
114
117
|
name: rake
|
115
|
-
requirement: &
|
118
|
+
requirement: &70237165715720 !ruby/object:Gem::Requirement
|
116
119
|
none: false
|
117
120
|
requirements:
|
118
121
|
- - ! '>='
|
@@ -120,7 +123,7 @@ dependencies:
|
|
120
123
|
version: '0'
|
121
124
|
type: :development
|
122
125
|
prerelease: false
|
123
|
-
version_requirements: *
|
126
|
+
version_requirements: *70237165715720
|
124
127
|
description: Provides Ruby wrappers for the Ticket Evolution API (http://developer.ticketevolution.com).
|
125
128
|
Ticket Evolution is the industry leader in software for the Ticket Broker industry.
|
126
129
|
email:
|
@@ -144,6 +147,7 @@ files:
|
|
144
147
|
- lib/docs/introduction.markdown
|
145
148
|
- lib/docs/license.markdown
|
146
149
|
- lib/docs/objects.markdown
|
150
|
+
- lib/faraday/response/verbose_logger.rb
|
147
151
|
- lib/ticket_evolution.rb
|
148
152
|
- lib/ticket_evolution/account.rb
|
149
153
|
- lib/ticket_evolution/accounts.rb
|
@@ -214,6 +218,9 @@ files:
|
|
214
218
|
- spec/fixtures/net/endpoints/brokerages.yml
|
215
219
|
- spec/fixtures/net/endpoints/categories.yml
|
216
220
|
- spec/fixtures/net/endpoints/clients.yml
|
221
|
+
- spec/fixtures/net/endpoints/clients/create.yml
|
222
|
+
- spec/fixtures/net/endpoints/clients/update_fail.yml
|
223
|
+
- spec/fixtures/net/endpoints/clients/update_success.yml
|
217
224
|
- spec/fixtures/net/endpoints/search.yml
|
218
225
|
- spec/lib/ticket_evolution/account_spec.rb
|
219
226
|
- spec/lib/ticket_evolution/accounts_spec.rb
|
@@ -295,7 +302,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
295
302
|
version: '0'
|
296
303
|
segments:
|
297
304
|
- 0
|
298
|
-
hash: -
|
305
|
+
hash: -1170424389658558163
|
299
306
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
300
307
|
none: false
|
301
308
|
requirements:
|
@@ -315,6 +322,9 @@ test_files:
|
|
315
322
|
- spec/fixtures/net/endpoints/brokerages.yml
|
316
323
|
- spec/fixtures/net/endpoints/categories.yml
|
317
324
|
- spec/fixtures/net/endpoints/clients.yml
|
325
|
+
- spec/fixtures/net/endpoints/clients/create.yml
|
326
|
+
- spec/fixtures/net/endpoints/clients/update_fail.yml
|
327
|
+
- spec/fixtures/net/endpoints/clients/update_success.yml
|
318
328
|
- spec/fixtures/net/endpoints/search.yml
|
319
329
|
- spec/lib/ticket_evolution/account_spec.rb
|
320
330
|
- spec/lib/ticket_evolution/accounts_spec.rb
|