seatgeek 0.1.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0417f52b7a1ee59a497f30206bc19bf2aa09df1e
4
- data.tar.gz: d08f67022f031051b7d1f875ff1e299d16c433d0
3
+ metadata.gz: 4fff0f590450a4239ba544957b7015ef1e7a5a5e
4
+ data.tar.gz: dd74c176439117ac90b7e54d71eff24ff3df1b3c
5
5
  SHA512:
6
- metadata.gz: 5a7c01abfa900e5ca64a52c363517a15c3be9b2eef708f6201269c1fc1afe3b8f7b64dc0a3bee8d88ee8d2918f73f6ca595e33d91937849c8b4c4b438d82e664
7
- data.tar.gz: 1f73bbb1e4f7dacd26c2b35d47358b1a8129223b897706cbc31ce33f1d91201ccfefa8ccc2b078511b37e9bd52ee8d04bc7d88eaea1b799907a8fd6e466c21b9
6
+ metadata.gz: ee80b3beca64bd2804568275f0664083157429923832700b0328682ac0473f864e3da469fe1f521591162c9fb69ab18172500c4f9c0a35951f4a899dd5b8a751
7
+ data.tar.gz: 4314cf7470e706942425395ab5996269555a248f27e08860fcec58db6c306a383afe952fd0d4b4b8980ec205f1e42eabf20921c63de674f7fa230054ec3c4eb3
data/.gitignore CHANGED
@@ -1,5 +1,33 @@
1
1
  .DS_Store
2
- *.swp
3
- *.swo
4
- pkg
2
+
3
+ *.gem
4
+ *.rbc
5
+ /.config
6
+ /coverage/
7
+ /InstalledFiles
8
+ /pkg/
9
+ /spec/reports/
10
+ /spec/examples.txt
11
+ /test/tmp/
12
+ /test/version_tmp/
13
+ /tmp/
14
+
15
+ ## Documentation cache and generated files:
16
+ /.yardoc/
17
+ /_yardoc/
18
+ /doc/
19
+ /rdoc/
20
+
21
+ ## Environment normalization:
22
+ /.bundle/
23
+ /vendor/bundle
24
+ /lib/bundler/man/
25
+
26
+ # for a library or gem, you might want to ignore these files since the code is
27
+ # intended to run in multiple environments; otherwise, check them in:
28
+ # Gemfile.lock
29
+ # .ruby-version
30
+ # .ruby-gemset
31
+
32
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
5
33
  .rvmrc
@@ -1,8 +1,7 @@
1
1
  bundler_args: --without no_travis
2
2
  language: ruby
3
3
  rvm:
4
- - ree
5
- - 1.8.7
6
4
  - 1.9.2
5
+ - 2.1.0
7
6
  gemfile:
8
7
  - Gemfile
data/Gemfile CHANGED
@@ -1,17 +1,17 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'faraday'
4
- gem 'multi_json'
5
- gem 'rake'
6
- gem 'yajl-ruby'
3
+ gem 'faraday', '~> 0.8.11'
4
+ gem 'multi_json', '~> 1.3.5'
5
+ gem 'rake', '~> 0.9.2'
6
+ gem 'yajl-ruby', '~> 1.1.0'
7
7
 
8
8
  group :test do
9
- gem 'rspec'
9
+ gem 'rspec', '~> 3.4.0'
10
10
  end
11
11
 
12
12
  group :no_travis do
13
- gem 'awesome_print'
14
- RUBY_VERSION =~ /^1\.9/ ? gem('ruby-debug19') : gem('ruby-debug')
13
+ gem 'awesome_print', '~> 1.6.1'
14
+ gem 'debugger', '~> 1.6.8'
15
15
  end
16
16
 
17
17
  gemspec
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- seatgeek (0.1.2)
4
+ seatgeek (0.1.3)
5
5
  faraday
6
6
  multi_json
7
7
  rake
@@ -10,29 +10,47 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- diff-lcs (1.1.3)
14
- faraday (0.8.0)
15
- multipart-post (~> 1.1)
16
- multi_json (1.3.5)
17
- multipart-post (1.1.5)
18
- rake (0.9.2.2)
19
- rspec (2.10.0)
20
- rspec-core (~> 2.10.0)
21
- rspec-expectations (~> 2.10.0)
22
- rspec-mocks (~> 2.10.0)
23
- rspec-core (2.10.0)
24
- rspec-expectations (2.10.0)
25
- diff-lcs (~> 1.1.3)
26
- rspec-mocks (2.10.1)
13
+ awesome_print (1.6.1)
14
+ columnize (0.9.0)
15
+ debugger (1.6.8)
16
+ columnize (>= 0.3.1)
17
+ debugger-linecache (~> 1.2.0)
18
+ debugger-ruby_core_source (~> 1.3.5)
19
+ debugger-linecache (1.2.0)
20
+ debugger-ruby_core_source (1.3.8)
21
+ diff-lcs (1.2.5)
22
+ faraday (0.8.11)
23
+ multipart-post (~> 1.2.0)
24
+ multi_json (1.3.7)
25
+ multipart-post (1.2.0)
26
+ rake (0.9.6)
27
+ rspec (3.4.0)
28
+ rspec-core (~> 3.4.0)
29
+ rspec-expectations (~> 3.4.0)
30
+ rspec-mocks (~> 3.4.0)
31
+ rspec-core (3.4.4)
32
+ rspec-support (~> 3.4.0)
33
+ rspec-expectations (3.4.0)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.4.0)
36
+ rspec-mocks (3.4.1)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.4.0)
39
+ rspec-support (3.4.1)
27
40
  yajl-ruby (1.1.0)
28
41
 
29
42
  PLATFORMS
30
43
  ruby
31
44
 
32
45
  DEPENDENCIES
33
- faraday
34
- multi_json
35
- rake
36
- rspec
46
+ awesome_print (~> 1.6.1)
47
+ debugger (~> 1.6.8)
48
+ faraday (~> 0.8.11)
49
+ multi_json (~> 1.3.5)
50
+ rake (~> 0.9.2)
51
+ rspec (~> 3.4.0)
37
52
  seatgeek!
38
- yajl-ruby
53
+ yajl-ruby (~> 1.1.0)
54
+
55
+ BUNDLED WITH
56
+ 1.11.2
data/README.md CHANGED
@@ -9,8 +9,7 @@ For more information, including a detailed description of the functionality avai
9
9
  **Rubies supported**
10
10
 
11
11
  - 1.9.2
12
- - 1.8.7
13
- - ree
12
+ - 2.1.0
14
13
 
15
14
  Installation
16
15
  ------------
@@ -32,6 +31,10 @@ NOTE: Unless it is already defined in your application, SG will be defined as a
32
31
 
33
32
  SeatGeek::Connection is where all the meat is.
34
33
 
34
+ You will first need to provide the `client_id` for your application. For assistance registering and locating your `client_id`, please see [the platform documentation](http://platform.seatgeek.com/#authentication).
35
+
36
+ SeatGeek::Connection.client_id = 'some_client_id'
37
+
35
38
  Each of the four endpoints can be accessed with a class method reflecting the endpoint's name.
36
39
 
37
40
  SeatGeek::Connection.events
@@ -1,44 +1,95 @@
1
1
  require 'faraday'
2
2
 
3
+ ##
4
+ # Module: SeatGeek
3
5
  module SeatGeek
6
+ ##
7
+ # Class: Connection
4
8
  class Connection
5
9
  class << self; self; end.class_eval do
6
- def adapter; @@adapter ||= :net_http; end
7
- def adapter=(input); @@adapter = input; end
10
+ def adapter
11
+ @@adapter ||= :net_http
12
+ end
13
+
14
+ def adapter=(input)
15
+ @@adapter = input
16
+ end
17
+
18
+ def events(*args)
19
+ new.events(*args)
20
+ end
8
21
 
9
- def events(*args); new.events(*args); end
22
+ def logger
23
+ @@logger ||= nil
24
+ end
10
25
 
11
- def logger; @@logger ||= nil; end
12
- def logger=(input); @@logger = input; end
26
+ def logger=(input)
27
+ @@logger = input
28
+ end
13
29
 
14
30
  def options
15
31
  {
16
- :adapter => adapter,
17
- :logger => logger,
18
- :protocol => protocol,
19
- :response_format => response_format,
20
- :url => url,
21
- :version => version
32
+ adapter: adapter,
33
+ logger: logger,
34
+ protocol: protocol,
35
+ response_format: response_format,
36
+ url: url,
37
+ version: version,
38
+ client_id: client_id
22
39
  }
23
40
  end
24
41
 
25
- def performers(*args); new.performers(*args); end
42
+ def performers(*args)
43
+ new.performers(*args)
44
+ end
45
+
46
+ def protocol
47
+ @@protocol ||= :https
48
+ end
26
49
 
27
- def protocol; @@protocol ||= :https; end
28
- def protocol=(input); @@protocol = input; end
50
+ def protocol=(input)
51
+ @@protocol = input
52
+ end
29
53
 
30
- def response_format; @@response_format ||= :ruby; end
31
- def response_format=(input); @@response_format = input; end
54
+ def response_format
55
+ @@response_format ||= :ruby
56
+ end
32
57
 
33
- def taxonomies(*args); new.taxonomies(*args); end
58
+ def response_format=(input)
59
+ @@response_format = input
60
+ end
34
61
 
35
- def url; @@url ||= "api.seatgeek.com"; end
36
- def url=(input); @@url = input; end
62
+ def taxonomies(*args)
63
+ new.taxonomies(*args)
64
+ end
37
65
 
38
- def venues(*args); new.venues(*args); end
66
+ def url
67
+ @@url ||= 'api.seatgeek.com'
68
+ end
39
69
 
40
- def version; @@version ||= 2; end
41
- def version=(input); @@version = input; end
70
+ def url=(input)
71
+ @@url = input
72
+ end
73
+
74
+ def venues(*args)
75
+ new.venues(*args)
76
+ end
77
+
78
+ def version
79
+ @@version ||= 2
80
+ end
81
+
82
+ def version=(input)
83
+ @@version = input
84
+ end
85
+
86
+ def client_id
87
+ @@client_id ||= nil
88
+ end
89
+
90
+ def client_id=(input)
91
+ @@client_id = input
92
+ end
42
93
  end
43
94
 
44
95
  def initialize(options = {})
@@ -54,26 +105,25 @@ module SeatGeek
54
105
  end
55
106
 
56
107
  def handle_response(response)
57
- if response_format == :ruby and response.status == 200
108
+ if response_format == :ruby && response.status == 200
58
109
  MultiJson.decode(response.body)
59
110
  else
60
- {:status => response.status, :body => response.body}
111
+ { status: response.status, body: response.body }
61
112
  end
62
113
  end
63
114
 
64
- # Ruby 1.8.7 / ree compatibility
65
- def id
66
- @options[:id]
67
- end
68
-
69
115
  def performers(params = {})
70
116
  request('/performers', params)
71
117
  end
72
118
 
73
119
  def request(url, params)
120
+ raise 'You must provide a `client_id` for SeatGeek' unless client_id || params[:client_id]
74
121
  handle_response(Faraday.new(*builder(url, params.clone)) do |build|
75
- build.adapter adapter
122
+ if client_id
123
+ build.use Faraday::Request::BasicAuthentication, client_id, nil
124
+ end
76
125
  build.use Faraday::Response::VerboseLogger, logger unless logger.nil?
126
+ build.adapter adapter
77
127
  end.get)
78
128
  end
79
129
 
@@ -100,15 +150,14 @@ module SeatGeek
100
150
  end
101
151
 
102
152
  def builder(uri_segment, params)
103
- return [
153
+ [
104
154
  uri([].tap do |part|
105
155
  part << uri_segment
106
156
  part << "/#{params.delete(:id)}" unless params[:id].nil?
107
157
  end.join),
108
158
  {
109
- :params => custom_options.merge((
110
- [:jsonp, :xml].include?(response_format) ? \
111
- params.merge(:format => response_format) : params))
159
+ params: custom_options.merge((
160
+ [:jsonp, :xml].include?(response_format) ? params.merge(format: response_format) : params))
112
161
  }
113
162
  ]
114
163
  end
@@ -1,3 +1,5 @@
1
+ ##
2
+ # Module: SeatGeek
1
3
  module SeatGeek
2
- VERSION = "0.1.3"
4
+ VERSION = '1.0.0'
3
5
  end
@@ -0,0 +1 @@
1
+ {"meta":{"per_page":1,"total":63188,"page":1,"took":4,"geolocation":null},"events":[{"stats":{"listing_count":0,"average_price":0,"lowest_price":null,"highest_price":null},"relative_url":"/palm-beach-cardinals-at-jupiter-hammerheads-tickets/minor-league-baseball/2012-05-14/798459/","title":"Palm Beach Cardinals at Jupiter Hammerheads","url":"https://seatgeek.com/palm-beach-cardinals-at-jupiter-hammerheads-tickets/minor-league-baseball/2012-05-14/798459/","datetime_local":"2012-05-14T10:35:00","performers":[{"away_team":true,"name":"Palm Beach Cardinals","url":"https://seatgeek.com/palm-beach-cardinals-tickets/","image":null,"short_name":"Palm Beach Cardinals","slug":"palm-beach-cardinals","score":0,"images":[],"type":"minor_league_baseball","id":9420},{"home_team":true,"name":"Jupiter Hammerheads","url":"https://seatgeek.com/jupiter-hammerheads-tickets/","image":null,"short_name":"Jupiter Hammerheads","primary":true,"slug":"jupiter-hammerheads","score":0,"images":[],"type":"minor_league_baseball","id":9421}],"venue":{"city":"Jupiter","name":"Roger Dean Stadium","url":"https://seatgeek.com/roger-dean-stadium-tickets/","country":"US","state":"FL","score":16592,"postal_code":"33468","location":{"lat":26.8936,"lon":-80.1156},"extended_address":null,"address":"4751 Main St","id":3927},"short_title":"Palm Beach Cardinals at Jupiter Hammerheads","datetime_utc":"2012-05-14T14:35:00","score":0,"taxonomies":[{"parent_id":null,"id":1000000,"name":"sports"},{"parent_id":1000000,"id":1010000,"name":"baseball"},{"parent_id":1010000,"id":1010300,"name":"minor_league_baseball"}],"type":"minor_league_baseball","id":798459}]}
@@ -3,281 +3,339 @@ require 'ostruct'
3
3
 
4
4
  describe SeatGeek::Connection do
5
5
  let(:klass) { SeatGeek::Connection }
6
- let(:instance) { klass.new }
6
+ let(:instance) { klass.new(client_id: 'foobar') }
7
7
 
8
- describe ".adapter" do
8
+ describe '.adapter' do
9
9
  subject { klass.adapter }
10
10
  let(:default) { :net_http }
11
11
 
12
12
  it { should == default }
13
- it "should be writable" do
13
+ it 'should be writable' do
14
14
  klass.adapter = :typhoeus
15
- klass.adapter.should == :typhoeus
15
+ expect(klass.adapter).to eq(:typhoeus)
16
16
  end
17
17
 
18
18
  after { klass.adapter = default }
19
19
  end
20
20
 
21
- describe ".events" do
22
- it "proxies to #events" do
23
- klass.any_instance.should_receive(:events).and_return(nil)
21
+ describe '.events' do
22
+ it 'proxies to #events' do
23
+ expect_any_instance_of(klass).to receive(:events).and_return(nil)
24
24
  klass.events
25
25
  end
26
26
 
27
- it "passes any attributes to #events" do
28
- klass.any_instance.should_receive(:events).with(1, 2).and_return(nil)
27
+ it 'passes any attributes to #events' do
28
+ expect_any_instance_of(klass).to receive(:events).with(1, 2)
29
+ .and_return(nil)
29
30
  klass.events(1, 2)
30
31
  end
31
32
  end
32
33
 
33
- describe ".logger" do
34
+ describe '.logger' do
34
35
  subject { klass.logger }
35
36
  let(:default) { nil }
36
37
  let(:logger) { Logger.new(STDOUT) }
37
38
 
38
39
  it { should == default }
39
- it "should be writable" do
40
+ it 'should be writable' do
40
41
  klass.logger = logger
41
- klass.logger.should == logger
42
+ expect(klass.logger).to eq(logger)
42
43
  end
43
44
 
44
45
  after { klass.logger = default }
45
46
  end
46
47
 
47
- describe ".options" do
48
- it "should return a hash of all of the class level settings" do
49
- klass.options.should == {
50
- :adapter => :net_http,
51
- :logger => nil,
52
- :protocol => :https,
53
- :response_format => :ruby,
54
- :url => "api.seatgeek.com",
55
- :version => 2
56
- }
48
+ describe '.options' do
49
+ it 'should return a hash of all of the class level settings' do
50
+ expect(klass.options).to eq(
51
+ adapter: :net_http,
52
+ logger: nil,
53
+ protocol: :https,
54
+ response_format: :ruby,
55
+ url: 'api.seatgeek.com',
56
+ version: 2,
57
+ client_id: nil
58
+ )
57
59
  end
58
60
  end
59
61
 
60
- describe ".performers" do
61
- it "proxies to #performers" do
62
- klass.any_instance.should_receive(:performers).and_return(nil)
62
+ describe '.performers' do
63
+ it 'proxies to #performers' do
64
+ expect_any_instance_of(klass).to receive(:performers).and_return(nil)
63
65
  klass.performers
64
66
  end
65
67
 
66
- it "passes any attributes to #performers" do
67
- klass.any_instance.should_receive(:performers).with(1, 2).and_return(nil)
68
+ it 'passes any attributes to #performers' do
69
+ expect_any_instance_of(klass).to receive(:performers).with(1, 2)
70
+ .and_return(nil)
68
71
  klass.performers(1, 2)
69
72
  end
70
73
  end
71
74
 
72
- describe ".protocol" do
75
+ describe '.protocol' do
73
76
  subject { klass.protocol }
74
77
  let(:default) { :https }
75
78
 
76
79
  it { should == default }
77
- it "should be writable" do
80
+ it 'should be writable' do
78
81
  klass.protocol = :https
79
- klass.protocol.should == :https
82
+ expect(klass.protocol).to eq(:https)
80
83
  end
81
84
 
82
85
  after { klass.protocol = default }
83
86
  end
84
87
 
85
- describe ".response_format" do
88
+ describe '.client_id' do
89
+ subject { klass.client_id }
90
+ let(:default) { nil }
91
+
92
+ it { should == default }
93
+ it 'should be writable' do
94
+ klass.client_id = 'some_client_id'
95
+ expect(klass.client_id).to eq('some_client_id')
96
+ end
97
+
98
+ after { klass.client_id = default }
99
+ end
100
+
101
+ describe '.response_format' do
86
102
  subject { klass.response_format }
87
103
  let(:default) { :ruby }
88
104
 
89
105
  it { should == default }
90
- it "should be writable" do
106
+ it 'should be writable' do
91
107
  klass.response_format = :jsonp
92
- klass.response_format.should == :jsonp
108
+ expect(klass.response_format).to eq(:jsonp)
93
109
  end
94
110
 
95
111
  after { klass.response_format = default }
96
112
  end
97
113
 
98
- describe ".taxonomies" do
99
- it "proxies to #taxonomies" do
100
- klass.any_instance.should_receive(:taxonomies).and_return(nil)
114
+ describe '.taxonomies' do
115
+ it 'proxies to #taxonomies' do
116
+ expect_any_instance_of(klass).to receive(:taxonomies).and_return(nil)
101
117
  klass.taxonomies
102
118
  end
103
119
 
104
- it "passes any attributes to #taxonomies" do
105
- klass.any_instance.should_receive(:taxonomies).with(1, 2).and_return(nil)
120
+ it 'passes any attributes to #taxonomies' do
121
+ expect_any_instance_of(klass).to receive(:taxonomies).with(1, 2)
122
+ .and_return(nil)
106
123
  klass.taxonomies(1, 2)
107
124
  end
108
125
  end
109
126
 
110
- describe ".url" do
127
+ describe '.url' do
111
128
  subject { klass.url }
112
- let(:default) { "api.seatgeek.com" }
129
+ let(:default) { 'api.seatgeek.com' }
113
130
 
114
131
  it { should == default }
115
- it "should be writable" do
116
- klass.url = "ticketevolution.com"
117
- klass.url.should == "ticketevolution.com"
132
+ it 'should be writable' do
133
+ klass.url = 'ticketevolution.com'
134
+ expect(klass.url).to eq('ticketevolution.com')
118
135
  end
119
136
 
120
137
  after { klass.url = default }
121
138
  end
122
139
 
123
- describe ".venues" do
124
- it "proxies to #venues" do
125
- klass.any_instance.should_receive(:venues).and_return(nil)
140
+ describe '.venues' do
141
+ it 'proxies to #venues' do
142
+ expect_any_instance_of(klass).to receive(:venues).and_return(nil)
126
143
  klass.venues
127
144
  end
128
145
 
129
- it "passes any attributes to #venues" do
130
- klass.any_instance.should_receive(:venues).with(1, 2).and_return(nil)
146
+ it 'passes any attributes to #venues' do
147
+ expect_any_instance_of(klass).to receive(:venues).with(1, 2)
148
+ .and_return(nil)
131
149
  klass.venues(1, 2)
132
150
  end
133
151
  end
134
152
 
135
- describe ".version" do
153
+ describe '.version' do
136
154
  subject { klass.version }
137
155
  let(:default) { 2 }
138
156
 
139
157
  it { should == 2 }
140
- it "should be writable" do
158
+ it 'should be writable' do
141
159
  klass.version = 1
142
- klass.version.should == 1
160
+ expect(klass.version).to eq(1)
143
161
  end
144
162
 
145
163
  after { klass.version = default }
146
164
  end
147
165
 
148
- describe "#initialize" do
166
+ describe '#initialize' do
149
167
  let(:expected) { klass.options.merge(options) }
150
- let(:options) { { :testing => 123, :clone => :hello } }
151
- let(:str_options) { {}.tap{|o| options.each{|k, v| o[k.to_s] = v}} }
168
+ let(:options) { { testing: 123, clone: 'hello', client_id: 'some_data' } }
169
+ let(:str_options) { {}.tap { |o| options.each { |k, v| o[k.to_s] = v } } }
152
170
  let(:instance) { klass.new(options) }
153
171
 
154
- it "should take options passed and store them on top of the class options hash" do
155
- instance.instance_eval('@options').should == expected
172
+ it 'should take options passed and store '\
173
+ 'them on top of the class options hash' do
174
+ expect(instance.instance_eval('@options')).to eq(expected)
156
175
  end
157
176
 
158
- it "should convert the keys passed to symbols" do
159
- klass.new(str_options).instance_eval('@options').should == expected
177
+ it 'should convert the keys passed to symbols' do
178
+ expect(klass.new(str_options).instance_eval('@options')).to eq(expected)
160
179
  end
161
180
 
162
- it "should serve options up via read accessor methods unless the methods already exist" do
163
- instance.testing.should == options[:testing]
164
- instance.clone.should_not == options[:clone]
181
+ it 'should serve options up via read accessor '\
182
+ 'methods unless the methods already exist' do
183
+ expect(instance.testing).to eq(options[:testing])
184
+ expect(instance.clone).not_to eq(options[:clone])
165
185
  end
166
186
  end
167
187
 
168
- describe "#events" do
169
- let(:url) { '/events'}
170
- let(:params) { {:test => 123} }
188
+ describe '#events' do
189
+ let(:url) { '/events' }
190
+ let(:params) { { test: 123 } }
171
191
 
172
- it "should call #request with the correct url segment and the params passed" do
173
- instance.should_receive(:request).with(url, params)
192
+ it 'should call #request with the correct'\
193
+ 'url segment and the params passed' do
194
+ expect(instance).to receive(:request).with(url, params)
174
195
  instance.events(params)
175
196
  end
176
197
  end
177
198
 
178
- describe "#handle_response" do
179
- let(:response) { double(Faraday::Response, :status => status, :body => body)}
199
+ describe '#handle_response' do
200
+ let(:response) { double(Faraday::Response, status: status, body: body) }
180
201
 
181
- context "when response_format is set to ruby" do
182
- context "and the request was successful" do
202
+ context 'when response_format is set to ruby' do
203
+ context 'and the request was successful' do
183
204
  let(:status) { 200 }
184
- let(:body) { "{\"meta\":{\"per_page\":1,\"total\":63188,\"page\":1,\"took\":4,\"geolocation\":null},\"events\":[{\"stats\":{\"listing_count\":0,\"average_price\":0,\"lowest_price\":null,\"highest_price\":null},\"relative_url\":\"/palm-beach-cardinals-at-jupiter-hammerheads-tickets/minor-league-baseball/2012-05-14/798459/\",\"title\":\"Palm Beach Cardinals at Jupiter Hammerheads\",\"url\":\"https://seatgeek.com/palm-beach-cardinals-at-jupiter-hammerheads-tickets/minor-league-baseball/2012-05-14/798459/\",\"datetime_local\":\"2012-05-14T10:35:00\",\"performers\":[{\"away_team\":true,\"name\":\"Palm Beach Cardinals\",\"url\":\"https://seatgeek.com/palm-beach-cardinals-tickets/\",\"image\":null,\"short_name\":\"Palm Beach Cardinals\",\"slug\":\"palm-beach-cardinals\",\"score\":0,\"images\":[],\"type\":\"minor_league_baseball\",\"id\":9420},{\"home_team\":true,\"name\":\"Jupiter Hammerheads\",\"url\":\"https://seatgeek.com/jupiter-hammerheads-tickets/\",\"image\":null,\"short_name\":\"Jupiter Hammerheads\",\"primary\":true,\"slug\":\"jupiter-hammerheads\",\"score\":0,\"images\":[],\"type\":\"minor_league_baseball\",\"id\":9421}],\"venue\":{\"city\":\"Jupiter\",\"name\":\"Roger Dean Stadium\",\"url\":\"https://seatgeek.com/roger-dean-stadium-tickets/\",\"country\":\"US\",\"state\":\"FL\",\"score\":16592,\"postal_code\":\"33468\",\"location\":{\"lat\":26.8936,\"lon\":-80.1156},\"extended_address\":null,\"address\":\"4751 Main St\",\"id\":3927},\"short_title\":\"Palm Beach Cardinals at Jupiter Hammerheads\",\"datetime_utc\":\"2012-05-14T14:35:00\",\"score\":0,\"taxonomies\":[{\"parent_id\":null,\"id\":1000000,\"name\":\"sports\"},{\"parent_id\":1000000,\"id\":1010000,\"name\":\"baseball\"},{\"parent_id\":1010000,\"id\":1010300,\"name\":\"minor_league_baseball\"}],\"type\":\"minor_league_baseball\",\"id\":798459}]}" }
205
+ let(:body) { File.read('spec/fixtures/handle_response.json') }
185
206
 
186
- it "should parse the json returned and respond with a ruby object" do
187
- instance.handle_response(response).should == MultiJson.decode(body)
207
+ it 'should parse the json returned and respond with a ruby object' do
208
+ expect(instance.handle_response(response))
209
+ .to eq(MultiJson.decode(body))
188
210
  end
189
211
  end
190
212
 
191
- context "and the request was not successful" do
213
+ context 'and the request was not successful' do
192
214
  let(:status) { 500 }
193
- let(:body) { "Internal Server Error" }
215
+ let(:body) { 'Internal Server Error' }
194
216
 
195
- it "should return the status code and exact result body" do
196
- instance.handle_response(response).should == {:status => status, :body => body}
217
+ it 'should return the status code and exact result body' do
218
+ expect(instance.handle_response(response))
219
+ .to eq(status: status, body: body)
197
220
  end
198
221
  end
199
222
  end
200
223
 
201
- context "when response format is not set to ruby" do
224
+ context 'when response format is not set to ruby' do
202
225
  let(:status) { 200 }
203
- let(:body) { "{\"meta\":{\"per_page\":1,\"total\":63188,\"page\":1,\"took\":4,\"geolocation\":null},\"events\":[{\"stats\":{\"listing_count\":0,\"average_price\":0,\"lowest_price\":null,\"highest_price\":null},\"relative_url\":\"/palm-beach-cardinals-at-jupiter-hammerheads-tickets/minor-league-baseball/2012-05-14/798459/\",\"title\":\"Palm Beach Cardinals at Jupiter Hammerheads\",\"url\":\"https://seatgeek.com/palm-beach-cardinals-at-jupiter-hammerheads-tickets/minor-league-baseball/2012-05-14/798459/\",\"datetime_local\":\"2012-05-14T10:35:00\",\"performers\":[{\"away_team\":true,\"name\":\"Palm Beach Cardinals\",\"url\":\"https://seatgeek.com/palm-beach-cardinals-tickets/\",\"image\":null,\"short_name\":\"Palm Beach Cardinals\",\"slug\":\"palm-beach-cardinals\",\"score\":0,\"images\":[],\"type\":\"minor_league_baseball\",\"id\":9420},{\"home_team\":true,\"name\":\"Jupiter Hammerheads\",\"url\":\"https://seatgeek.com/jupiter-hammerheads-tickets/\",\"image\":null,\"short_name\":\"Jupiter Hammerheads\",\"primary\":true,\"slug\":\"jupiter-hammerheads\",\"score\":0,\"images\":[],\"type\":\"minor_league_baseball\",\"id\":9421}],\"venue\":{\"city\":\"Jupiter\",\"name\":\"Roger Dean Stadium\",\"url\":\"https://seatgeek.com/roger-dean-stadium-tickets/\",\"country\":\"US\",\"state\":\"FL\",\"score\":16592,\"postal_code\":\"33468\",\"location\":{\"lat\":26.8936,\"lon\":-80.1156},\"extended_address\":null,\"address\":\"4751 Main St\",\"id\":3927},\"short_title\":\"Palm Beach Cardinals at Jupiter Hammerheads\",\"datetime_utc\":\"2012-05-14T14:35:00\",\"score\":0,\"taxonomies\":[{\"parent_id\":null,\"id\":1000000,\"name\":\"sports\"},{\"parent_id\":1000000,\"id\":1010000,\"name\":\"baseball\"},{\"parent_id\":1010000,\"id\":1010300,\"name\":\"minor_league_baseball\"}],\"type\":\"minor_league_baseball\",\"id\":798459}]}" }
226
+ let(:body) { File.read('spec/fixtures/handle_response.json') }
204
227
 
205
- it "should return the status code and exact result body" do
206
- klass.new(:response_format => :json).\
207
- handle_response(response).should == {:status => status, :body => body}
228
+ it 'should return the status code and exact result body' do
229
+ expect(klass.new(response_format: :json).handle_response(response))
230
+ .to eq(status: status, body: body)
208
231
  end
209
232
  end
210
233
  end
211
234
 
212
- describe "#performers" do
213
- let(:url) { '/performers'}
214
- let(:params) { {:test => 123} }
235
+ describe '#performers' do
236
+ let(:url) { '/performers' }
237
+ let(:params) { { test: 123 } }
215
238
 
216
- it "should call #request with the correct url segment and the params passed" do
217
- instance.should_receive(:request).with(url, params)
239
+ it 'should call #request with the correct '\
240
+ 'url segment and the params passed' do
241
+ expect(instance).to receive(:request).with(url, params)
218
242
  instance.performers(params)
219
243
  end
220
244
  end
221
245
 
222
- describe "#request" do
246
+ describe '#request' do
223
247
  let(:uri_segment) { '/venues' }
224
248
  let(:url) { "https://api.seatgeek.com/2#{uri_segment}" }
225
249
  let(:params) { {} }
226
- let(:faraday) { mock(:faraday, :get => OpenStruct.new({:status => 200, :body => "[]"})) }
250
+ let(:faraday) { double(:faraday, get: OpenStruct.new(status: 200, body: '[]')) }
251
+
252
+ context 'when .client_id is not set as class property' do
253
+ let(:instance) { klass.new }
254
+ let(:expected_params) { { params: params.merge(format: :jsonp) } }
255
+
256
+ it 'should throw an exception' do
257
+ expect { instance.request(uri_segment, params) }
258
+ .to raise_error('You must provide a `client_id` for SeatGeek')
259
+ end
260
+
261
+ it 'should not throw an exception if provided in paramters' do
262
+ expect {
263
+ params[:client_id] = 'foobar'
264
+ instance.request(uri_segment, params)
265
+ }.to_not raise_error
266
+ end
267
+ end
268
+
269
+ context 'when .response_format is jsonp' do
270
+ let(:instance) { klass.new(response_format: :jsonp, client_id: 'foobar') }
271
+ let(:expected_params) { { params: params.merge(format: :jsonp) } }
272
+
273
+ it 'should set the format param to jsonp' do
274
+ expect(Faraday).to receive(:new).with(url, expected_params)
275
+ .and_return(faraday)
276
+ instance.request(uri_segment, params)
277
+ end
278
+ end
227
279
 
228
- context "when .response_format is jsonp" do
229
- let(:instance) { klass.new({:response_format => :jsonp}) }
230
- let(:expected_params) { {:params => params.merge({:format => :jsonp})} }
280
+ context 'when .response_format is xml' do
281
+ let(:instance) { klass.new(response_format: :xml, client_id: 'foobar') }
282
+ let(:expected_params) { { params: params.merge(format: :xml) } }
231
283
 
232
- it "should set the format param to jsonp" do
233
- Faraday.should_receive(:new).with(url, expected_params).and_return(faraday)
284
+ it 'should set the format param to xml' do
285
+ expect(Faraday).to receive(:new).with(url, expected_params)
286
+ .and_return(faraday)
234
287
  instance.request(uri_segment, params)
235
288
  end
236
289
  end
237
290
 
238
- context "when .response_format is xml" do
239
- let(:instance) { klass.new({:response_format => :xml}) }
240
- let(:expected_params) { {:params => params.merge({:format => :xml})} }
291
+ context 'when additional parameters were passed to #initialize' do
292
+ let(:instance) { klass.new(response_format: :jsonp, testing: 123, client_id: 'foobar') }
293
+ let(:expected_params) { { params: params.merge(format: :jsonp, testing: 123)} }
241
294
 
242
- it "should set the format param to xml" do
243
- Faraday.should_receive(:new).with(url, expected_params).and_return(faraday)
295
+ it 'should add those parameters to the request params' do
296
+ expect(Faraday).to receive(:new).with(url, expected_params)
297
+ .and_return(faraday)
244
298
  instance.request(uri_segment, params)
245
299
  end
246
300
  end
247
301
 
248
- context "when additional parameters were passed to #initialize" do
249
- let(:instance) { klass.new({:response_format => :jsonp, :testing => 123}) }
250
- let(:expected_params) { {:params => params.merge({:format => :jsonp, :testing => 123})} }
302
+ context 'when client_id was passed as a parameter' do
303
+ let(:instance) { klass.new }
304
+ let(:params) { { client_id: 'foobar' } }
305
+ let(:expected_params) { { params: params.merge(client_id: 'foobar') } }
251
306
 
252
- it "should add those parameters to the request params" do
253
- Faraday.should_receive(:new).with(url, expected_params).and_return(faraday)
307
+ it 'should make the request with the client_id parameter set' do
308
+ expect(Faraday).to receive(:new).with(url, expected_params)
309
+ .and_return(faraday)
254
310
  instance.request(uri_segment, params)
255
311
  end
256
312
  end
257
313
  end
258
314
 
259
- describe "#taxonomies" do
260
- let(:url) { '/taxonomies'}
261
- let(:params) { {:test => 123} }
315
+ describe '#taxonomies' do
316
+ let(:url) { '/taxonomies' }
317
+ let(:params) { { test: 123 } }
262
318
 
263
- it "should call #request with the correct url segment and the params passed" do
264
- instance.should_receive(:request).with(url, params)
319
+ it 'should call #request with the correct '\
320
+ 'url segment and the params passed' do
321
+ expect(instance).to receive(:request).with(url, params)
265
322
  instance.taxonomies(params)
266
323
  end
267
324
  end
268
325
 
269
- describe "#uri" do
270
- it "should take in a path and combine it with protocol, url and version" do
271
- instance.uri('/events').should == "https://api.seatgeek.com/2/events"
326
+ describe '#uri' do
327
+ it 'should take in a path and combine it with protocol, url and version' do
328
+ expect(instance.uri('/events')).to eq('https://api.seatgeek.com/2/events')
272
329
  end
273
330
  end
274
331
 
275
- describe "#venues" do
276
- let(:url) { '/venues'}
277
- let(:params) { {:test => 123} }
332
+ describe '#venues' do
333
+ let(:url) { '/venues' }
334
+ let(:params) { { test: 123 } }
278
335
 
279
- it "should call #request with the correct url segment and the params passed" do
280
- instance.should_receive(:request).with(url, params)
336
+ it 'should call #request with the correct '\
337
+ 'url segment and the params passed' do
338
+ expect(instance).to receive(:request).with(url, params)
281
339
  instance.venues(params)
282
340
  end
283
341
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SeatGeek::VERSION do
4
- it "should match a three segment version number format" do
5
- subject.should =~ /^\d+\.\d+\.\d+(rc\d+)?$/
4
+ it 'should match a three segment version number format' do
5
+ expect(subject).to match(/^\d+\.\d+\.\d+(rc\d+)?$/)
6
6
  end
7
7
  end
@@ -2,6 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe SG do
4
4
  it "should be a subclass of SeatGeek::Connection" do
5
- SG.ancestors.should include SeatGeek::Connection
5
+ expect(SG.ancestors).to include(SeatGeek::Connection)
6
6
  end
7
7
  end
@@ -1,7 +1,6 @@
1
1
  require 'seatgeek'
2
2
 
3
3
  RSpec.configure do |config|
4
- config.treat_symbols_as_metadata_keys_with_true_values = true
5
4
  config.run_all_when_everything_filtered = true
6
5
  config.filter_run :focus
7
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seatgeek
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Matthews
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-19 00:00:00.000000000 Z
11
+ date: 2016-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -103,6 +103,7 @@ files:
103
103
  - lib/seat_geek/version.rb
104
104
  - lib/seatgeek.rb
105
105
  - seatgeek.gemspec
106
+ - spec/fixtures/handle_response.json
106
107
  - spec/lib/seat_geek/connection_spec.rb
107
108
  - spec/lib/seat_geek/version_spec.rb
108
109
  - spec/lib/sg_spec.rb
@@ -131,6 +132,7 @@ signing_key:
131
132
  specification_version: 4
132
133
  summary: A Ruby wrapper for the SeatGeek Platform API.
133
134
  test_files:
135
+ - spec/fixtures/handle_response.json
134
136
  - spec/lib/seat_geek/connection_spec.rb
135
137
  - spec/lib/seat_geek/version_spec.rb
136
138
  - spec/lib/sg_spec.rb