google_contacts_api 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.6
1
+ 0.2.7
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{google_contacts_api}
8
- s.version = "0.2.6"
8
+ s.version = "0.2.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alvin Liang"]
@@ -1,7 +1,8 @@
1
1
  require 'active_support/core_ext'
2
2
 
3
3
  module GoogleContactsApi
4
- class UnauthorizedError < StandardError; end
4
+ class ApiError < StandardError; end
5
+ class UnauthorizedError < ApiError; end
5
6
 
6
7
  class Api
7
8
  # keep separate in case of new auth method
@@ -23,7 +24,8 @@ module GoogleContactsApi
23
24
  result = @oauth.get("#{BASE_URL}#{link}?#{params.to_query}", headers)
24
25
  # For the full HTML we're matching against, see the spec
25
26
  # TODO: This could be pretty fragile.
26
- raise UnauthorizedError if result.include?("Token invalid - Invalid AuthSub token.") && result.include?("Error 401")
27
+ raise UnauthorizedError if result.is_a?(Net::HTTPUnauthorized)
28
+ # raise UnauthorizedError if result.include?("Token invalid - Invalid AuthSub token.") && result.include?("Error 401")
27
29
  result
28
30
  end
29
31
 
@@ -9,5 +9,5 @@ require 'google_contacts_api/group'
9
9
  require 'google_contacts_api/contact'
10
10
 
11
11
  module GoogleContactsApi
12
- VERSION = "0.2.6"
12
+ VERSION = "0.2.7"
13
13
  end
@@ -35,7 +35,7 @@ describe "GoogleContactsApi" do
35
35
  </HTML>
36
36
  ERROR_HTML
37
37
  error_html.strip!
38
- oauth.stub(:get).and_return(error_html)
38
+ oauth.stub(:get).and_return(Net::HTTPUnauthorized.new("1.1", 401, error_html))
39
39
  api = GoogleContactsApi::Api.new(oauth)
40
40
  lambda { api.get("any url",
41
41
  {"param" => "param"},
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,7 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
  require 'rspec'
4
4
  require 'json'
5
5
  require 'hashie'
6
+ require 'net/http'
6
7
  require 'google_contacts_api'
7
8
 
8
9
  puts "Testing version #{GoogleContactsApi::VERSION}"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: google_contacts_api
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.6
5
+ version: 0.2.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Alvin Liang
@@ -157,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
157
157
  requirements:
158
158
  - - ">="
159
159
  - !ruby/object:Gem::Version
160
- hash: -4187729260507670250
160
+ hash: -3574435168097113310
161
161
  segments:
162
162
  - 0
163
163
  version: "0"