yelp 2.1.3 → 2.1.4

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: 56a26261a87144e796fc952682cf9d64a00fafa8
4
- data.tar.gz: d6ec8e7c5d4972ae6d7c73ad1e23c3757b2b1e87
3
+ metadata.gz: 3359fa1baa8262abf574a174c749cfd2b4132d77
4
+ data.tar.gz: c7f7b07c2af49c4ba54a6e98359f989ffd37b580
5
5
  SHA512:
6
- metadata.gz: ae8700880ac6d3ac60126062350109257a340afa3e26ba6e60fb9fc43585804c3844d25cbf56b4ac9d506ffdae5831ec58e0980aa24d7c77f34630e0949fe15b
7
- data.tar.gz: 9eaee0908609b12531a04de473d6633c79fd788f480b8f3421a78490e47def9a8717bc848e0d7a750a344995da72b61a4b6b1594b09b1d062869dd05b906adb5
6
+ metadata.gz: c83dc81b6f8f1304832638e887df98c01f9505fcb35ab79205335a9eefdfe35e94181da6a800c0b7185b580943c529af7bdd06e2946c9b69bd1ee0e7f6bab299
7
+ data.tar.gz: 72b5d04e94f14c9079625b851c9965de12081700989050196f75deab5ee05e5b8e7e5edc461b51f7873daf1188f9bacad3cd484ce60f2d6bcf7d7c8a9cc4d66a
data/README.md CHANGED
@@ -160,19 +160,10 @@ For specific response values check out the docs for the [Search API](http://www.
160
160
  4. Push to the branch (`git push origin my-new-feature`)
161
161
  5. Create new Pull Request
162
162
 
163
- Our rspec test suite expects environment variables to be populated with your Yelp API Access Tokens. If you use RVM, you could create a `.ruby-env` file in the repo root with contents like:
164
-
165
- ```
166
- YELP_CONSUMER_KEY=<YOUR_YELP_CONSUMER_KEY>
167
- YELP_CONSUMER_SECRET=<YOUR_YELP_CONSUMER_SECRET>
168
- YELP_TOKEN=<YOUR_YELP_TOKEN>
169
- YELP_TOKEN_SECRET=<YOUR_YELP_TOKEN_SECRET>
170
- ```
163
+ Our rspec test suite expects environment variables to be populated with your Yelp API Access Tokens.
171
164
 
172
165
  You can generate and find your Access Tokens at [https://www.yelp.com/developers/manage_api_keys](https://www.yelp.com/developers/manage_api_keys).
173
166
 
174
- (We've included `.ruby-env.example` to get you started. Be careful to remove the `.example`.)
175
-
176
167
  ### Git Workflow
177
168
 
178
169
  We are using the [git flow](http://nvie.com/posts/a-successful-git-branching-model/)
@@ -1,3 +1,4 @@
1
+ require 'erb'
1
2
  require 'json'
2
3
 
3
4
  require 'yelp/responses/business'
@@ -37,7 +38,7 @@ module Yelp
37
38
  # @param locale [Hash] a hash of supported locale-related parameters
38
39
  # @return [Faraday::Response] the raw response back from the connection
39
40
  def business_request(id, locale = {})
40
- result = @client.connection.get PATH + id, locale
41
+ result = @client.connection.get PATH + ERB::Util.url_encode(id), locale
41
42
  Error.check_for_error(result)
42
43
  result
43
44
  end
@@ -17,7 +17,7 @@ module Yelp
17
17
  # Take a search_request and return the formatted/structured
18
18
  # response from the API
19
19
  #
20
- # @param location [String] a string location of the neighboorhood,
20
+ # @param location [String] a string location of the neighborhood,
21
21
  # address, or city
22
22
  # @param params [Hash] a hash that corresponds to params on the API:
23
23
  # http://www.yelp.com/developers/documentation/v2/search_api#searchGP
@@ -1,3 +1,3 @@
1
1
  module Yelp
2
- VERSION = "2.1.3"
2
+ VERSION = "2.1.4"
3
3
  end
@@ -16,8 +16,8 @@ describe Yelp::Client do
16
16
  subject { client }
17
17
 
18
18
  context 'with valid configuration' do
19
- its(:configuration) { should be_a(Yelp::Configuration) }
20
- its(:configuration) { should be_frozen }
19
+ its(:configuration) { is_expected.to be_a Yelp::Configuration }
20
+ its(:configuration) { is_expected.to be_frozen }
21
21
 
22
22
  it 'should not be reconfigurable' do
23
23
  expect {
@@ -44,7 +44,7 @@ describe Yelp::Client do
44
44
 
45
45
  it 'should set the configuration values' do
46
46
  valid_api_keys.each do |key, value|
47
- expect(client.configuration.send(key)).to eql(value)
47
+ expect(client.configuration.send(key)).to eq(value)
48
48
  end
49
49
  end
50
50
 
@@ -52,8 +52,8 @@ describe Yelp::Client do
52
52
  expect { configure_client_with_api_keys(valid_api_keys) }.to raise_error
53
53
  end
54
54
 
55
- it { should be_a(Yelp::Configuration) }
56
- it { should be_frozen }
55
+ it { is_expected.to be_a Yelp::Configuration }
56
+ it { is_expected.to be_frozen }
57
57
  end
58
58
 
59
59
  context 'with invalid configuration' do
@@ -10,35 +10,35 @@ describe Yelp::Configuration do
10
10
  subject { configuration }
11
11
 
12
12
  Yelp::Configuration::AUTH_KEYS.each do |auth_key|
13
- its(auth_key) { should eql(api_keys[auth_key]) }
13
+ its(auth_key) { is_expected.to eq api_keys[auth_key] }
14
14
  end
15
15
  end
16
16
 
17
17
  describe '#auth_keys' do
18
18
  subject { configuration.auth_keys }
19
- it { should eql(api_keys) }
19
+ it { is_expected.to eq api_keys }
20
20
  end
21
21
 
22
- describe "#valid?" do
22
+ describe '#valid?' do
23
23
  subject { configuration.valid? }
24
24
 
25
- context "when keys are valid" do
26
- it { should be true }
25
+ context 'when keys are valid' do
26
+ it { is_expected.to be true }
27
27
  end
28
28
 
29
- context "when keys are not set" do
29
+ context 'when keys are not set' do
30
30
  let(:api_keys) { Hash.new }
31
- it { should be false }
31
+ it { is_expected.to be false }
32
32
  end
33
33
 
34
- context "when a key is an empty string" do
34
+ context 'when a key is an empty string' do
35
35
  let(:api_keys) { valid_api_keys.merge(consumer_key: '') }
36
- it { should be false }
36
+ it { is_expected.to be false }
37
37
  end
38
38
 
39
- context "when a key is nil" do
39
+ context 'when a key is nil' do
40
40
  let(:api_keys) { valid_api_keys.merge(token: nil) }
41
- it { should be false }
41
+ it { is_expected.to be false }
42
42
  end
43
43
  end
44
44
  end
@@ -6,7 +6,7 @@ describe Yelp::Endpoint::Business do
6
6
  let(:api_keys) { real_api_keys }
7
7
  let(:business) { 'yelp-san-francisco' }
8
8
  let(:client) { Yelp::Client.new(api_keys) }
9
- let(:locale) { Hash[lang: 'fr'] }
9
+ let(:locale) { {lang: 'fr'} }
10
10
 
11
11
  describe '#business' do
12
12
  subject {
@@ -15,21 +15,21 @@ describe Yelp::Endpoint::Business do
15
15
  end
16
16
  }
17
17
 
18
- it { should be_a(Yelp::Response::Business) }
19
- its('business.name') { should eql('Yelp') }
20
- its('business.url') { should include('yelp.com') }
21
- end
18
+ it { is_expected.to be_a(Yelp::Response::Business) }
19
+ its('business.name') { is_expected.to eq('Yelp') }
20
+ its('business.url') { is_expected.to include('yelp.com') }
22
21
 
23
- describe '#business locale' do
24
- subject {
25
- VCR.use_cassette('business_locale') do
26
- client.business(business, locale)
27
- end
28
- }
22
+ context 'with locale' do
23
+ subject {
24
+ VCR.use_cassette('business_locale') do
25
+ client.business(business, locale)
26
+ end
27
+ }
29
28
 
30
- it { should be_a(Yelp::Response::Business) }
31
- its('business.name') { should eql('Yelp') }
32
- its('business.url') { should include('yelp.fr') }
29
+ it { is_expected.to be_a(Yelp::Response::Business) }
30
+ its('business.name') { is_expected.to eq('Yelp') }
31
+ its('business.url') { is_expected.to include('yelp.fr') }
32
+ end
33
33
  end
34
34
 
35
35
  describe 'errors' do
@@ -5,7 +5,7 @@ describe Yelp::Endpoint::PhoneSearch do
5
5
 
6
6
  let(:api_keys) { real_api_keys }
7
7
  let(:phone) { '+14159083801' }
8
- let(:options) { { code: 'US', category: 'localflavor' } }
8
+ let(:options) { {code: 'US', category: 'localflavor'} }
9
9
  let(:client) { Yelp::Client.new(api_keys) }
10
10
 
11
11
  describe '#phone_search' do
@@ -15,7 +15,8 @@ describe Yelp::Endpoint::PhoneSearch do
15
15
  end
16
16
  }
17
17
 
18
- it { should be_a(Yelp::Response::PhoneSearch) }
18
+ it { is_expected.to be_a(Yelp::Response::PhoneSearch) }
19
+
19
20
  it 'should get results' do
20
21
  expect(results.businesses.size).to be > 0
21
22
  end
@@ -5,8 +5,7 @@ describe Yelp::Endpoint::Search do
5
5
 
6
6
  let(:api_keys) { real_api_keys }
7
7
  let(:location) { 'San Francisco' }
8
- let(:params) { Hash[term: 'restaurants',
9
- category_filter: 'discgolf'] }
8
+ let(:params) { {term: 'restaurants', category_filter: 'discgolf'} }
10
9
  let(:client) { Yelp::Client.new(api_keys) }
11
10
 
12
11
  describe '#search' do
@@ -16,17 +15,22 @@ describe Yelp::Endpoint::Search do
16
15
  end
17
16
  }
18
17
 
19
- it { should be_a(Yelp::Response::Search) }
18
+ it { is_expected.to be_a(Yelp::Response::Search) }
19
+
20
20
  it 'should get results' do
21
21
  expect(results.businesses.size).to be > 0
22
22
  end
23
23
  end
24
24
 
25
- describe '#search_bounding_box' do
26
- let(:bounding_box) { Hash[sw_latitude: 37.7577,
27
- sw_longitude: -122.4376,
28
- ne_latitude: 37.785381,
29
- ne_longitude: -122.391681] }
25
+ describe '#search_by_bounding_box' do
26
+ let(:bounding_box) {
27
+ {
28
+ sw_latitude: 37.7577,
29
+ sw_longitude: -122.4376,
30
+ ne_latitude: 37.785381,
31
+ ne_longitude: -122.391681,
32
+ }
33
+ }
30
34
 
31
35
  subject(:results) {
32
36
  VCR.use_cassette('search_bounding_box') do
@@ -37,11 +41,16 @@ describe Yelp::Endpoint::Search do
37
41
  it 'should get results' do
38
42
  expect(results.businesses.size).to be > 0
39
43
  end
44
+
45
+ context 'when params are empty' do
46
+ subject { -> { client.search_by_bounding_box({}, params) } }
47
+
48
+ it { is_expected.to raise_error(Yelp::Error::BoundingBoxNotComplete) }
49
+ end
40
50
  end
41
51
 
42
52
  describe '#search_by_coordinates' do
43
- let(:coordinates) { Hash[latitude: 37.7577,
44
- longitude: -122.4376] }
53
+ let(:coordinates) { {latitude: 37.7577, longitude: -122.4376} }
45
54
 
46
55
  subject(:results) {
47
56
  VCR.use_cassette('search_by_coordinates') do
@@ -52,19 +61,15 @@ describe Yelp::Endpoint::Search do
52
61
  it 'should get results' do
53
62
  expect(results.businesses.size).to be > 0
54
63
  end
55
- end
56
64
 
57
- describe 'errors' do
58
- context 'search' do
59
- it 'raises when #search_by_coordinates params are empty' do
60
- expect { client.search_by_coordinates({}, params) }.to raise_error(Yelp::Error::MissingLatLng)
61
- end
65
+ context 'when params are empty' do
66
+ subject { -> { client.search_by_coordinates({}, params) } }
62
67
 
63
- it 'raises when #search_by_bounding_box params are empty' do
64
- expect { client.search_by_bounding_box({}, params) }.to raise_error(Yelp::Error::BoundingBoxNotComplete)
65
- end
68
+ it { is_expected.to raise_error(Yelp::Error::MissingLatLng) }
66
69
  end
70
+ end
67
71
 
72
+ describe 'errors' do
68
73
  it_behaves_like 'a request error' do
69
74
  let(:request) { client.search(location) }
70
75
  end
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Yelp::Error do
4
- context '#from_request' do
5
- let(:response_body) { "{\"error\": {\"text\": \"error message\", \"id\": \"INTERNAL_ERROR\"}}" }
4
+ context 'from_request' do
5
+ let(:response_body) { '{"error": {"text": "error message", "id": "INTERNAL_ERROR"}}' }
6
6
  let(:good_response) { double('response', status: 200) }
7
7
  let(:bad_response) { double('response', status: 400, body: response_body) }
8
8
 
@@ -20,7 +20,7 @@ describe Yelp::Error do
20
20
  end
21
21
 
22
22
  context 'invalid parameter' do
23
- let(:response_body) { "{\"error\": {\"text\": \"One or more parameters are invalid in request\", \"id\": \"INVALID_PARAMETER\", \"field\": \"oauth_token\"}}" }
23
+ let(:response_body) { '{"error": {"text": "One or more parameters are invalid in request", "id": "INVALID_PARAMETER", "field": "oauth_token"}}' }
24
24
  let(:bad_response) { double('response', status: 400, body: response_body) }
25
25
 
26
26
  it 'should raise an invalid response error' do
@@ -34,9 +34,9 @@ describe Yelp::Error do
34
34
  Yelp::Error.check_for_error(bad_response)
35
35
  rescue Yelp::Error::InvalidParameter => e
36
36
  # verifies that StandardError message attribute is available
37
- expect(e.message).to eq("One or more parameters are invalid in request: oauth_token")
37
+ expect(e.message).to eq('One or more parameters are invalid in request: oauth_token')
38
38
  # verifies that we can get access to the specific field that was invalid
39
- expect(e.field).to eq("oauth_token")
39
+ expect(e.field).to eq('oauth_token')
40
40
  end
41
41
  end
42
42
 
@@ -2,21 +2,25 @@ require 'spec_helper'
2
2
 
3
3
  describe Yelp::Response::Base do
4
4
  describe '#initialize' do
5
- let(:json) { Hash['a' => 10, 'b' => 20] }
5
+ let(:json) { {'a' => 10, 'b' => 20} }
6
6
 
7
- subject(:base) { base = Yelp::Response::Base.new(json) }
7
+ subject(:base) { Yelp::Response::Base.new(json) }
8
8
 
9
- it { should be_a(Yelp::Response::Base) }
9
+ it { is_expected.to be_a Yelp::Response::Base }
10
10
 
11
11
  it 'should create variables' do
12
- expect(base.instance_variable_get('@a')).to eql 10
13
- expect(base.instance_variable_get('@b')).to eql 20
12
+ expect(base.instance_variable_get(:@a)).to eq 10
13
+ expect(base.instance_variable_get(:@b)).to eq 20
14
14
  end
15
- end
16
15
 
17
- describe '#initialize nil' do
18
- subject(:base) { Yelp::Response::Base.new(nil) }
16
+ context 'when json is nil' do
17
+ let(:json) { nil }
18
+
19
+ it { is_expected.to be_a Yelp::Response::Base }
19
20
 
20
- it { should be_a(Yelp::Response::Base) }
21
+ it 'should not have variables' do
22
+ expect(base.instance_variable_get(:@a)).to be nil
23
+ end
24
+ end
21
25
  end
22
26
  end
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Yelp do
4
- describe "#client" do
4
+ describe '::client' do
5
5
  subject { Yelp.client }
6
6
 
7
- it { should be_a(Yelp::Client) }
8
- its(:configuration) { should be_nil }
7
+ it { is_expected.to be_a Yelp::Client }
8
+ its(:configuration) { is_expected.to be nil }
9
9
  end
10
- end
10
+ end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.required_ruby_version = '>= 1.9.2'
21
+ spec.required_ruby_version = '>= 2.0.0'
22
22
 
23
23
  spec.add_development_dependency 'bundler', '~> 1.5'
24
24
  spec.add_development_dependency 'rake', '~> 10.0', '>= 10.0.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yelp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomer Elmalem
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-07-08 00:00:00.000000000 Z
13
+ date: 2016-11-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -211,7 +211,6 @@ extensions: []
211
211
  extra_rdoc_files: []
212
212
  files:
213
213
  - ".gitignore"
214
- - ".ruby-env.example"
215
214
  - ".ruby-gemset"
216
215
  - ".ruby-version"
217
216
  - ".travis.yml"
@@ -274,7 +273,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
274
273
  requirements:
275
274
  - - ">="
276
275
  - !ruby/object:Gem::Version
277
- version: 1.9.2
276
+ version: 2.0.0
278
277
  required_rubygems_version: !ruby/object:Gem::Requirement
279
278
  requirements:
280
279
  - - ">="
@@ -1,6 +0,0 @@
1
- # Replace <THESE_VALUES> with yours from
2
- # https://www.yelp.com/developers/manage_api_keys (don't include <brackets>).
3
- YELP_CONSUMER_KEY=<YOUR_YELP_CONSUMER_KEY>
4
- YELP_CONSUMER_SECRET=<YOUR_YELP_CONSUMER_SECRET>
5
- YELP_TOKEN=<YOUR_YELP_TOKEN>
6
- YELP_TOKEN_SECRET=<YOUR_YELP_TOKEN_SECRET>