Permalink
Browse files

Add ability to provide custom api url for internal testing purposes

  • Loading branch information...
kyledrake committed Oct 9, 2012
1 parent c36135e commit 9e3c136a5b88bc163cbe19735b60bf6d15d9ec4b
Showing with 20 additions and 2 deletions.
  1. +5 −0 lib/geoloqi/config.rb
  2. +4 −1 lib/geoloqi/session.rb
  3. +1 −1 lib/geoloqi/version.rb
  4. +10 −0 spec/geoloqi/config_spec.rb
View
@@ -16,6 +16,11 @@ class Config
# @return [String]
attr_accessor :redirect_uri
+ # Which API URL to use for Geoloqi. You shouldn't need to change this.
+ #
+ # @return [String]
+ attr_accessor :api_url
+
# Which HTTP adapter to use for Faraday. Defaults to :net_http
#
# @return [Symbol]
View
@@ -40,7 +40,10 @@ def initialize(opts={})
self.auth = opts[:auth] || {}
self.auth[:access_token] = opts[:access_token] if opts[:access_token]
- @connection = Faraday.new(:url => Geoloqi.api_url, :ssl => {:verify => true, :ca_file => Geoloqi::SSL_CERT_FILE}) do |builder|
+ @connection = Faraday.new(
+ :url => (@config.api_url || Geoloqi.api_url),
+ :ssl => {:verify => true, :ca_file => Geoloqi::SSL_CERT_FILE}
+ ) do |builder|
builder.adapter @config.adapter || :net_http
end
end
View
@@ -3,6 +3,6 @@ module Geoloqi
#
# @return [String]
def self.version
- '0.9.43'
+ '0.9.44'
end
end
@@ -16,6 +16,16 @@
end
end
+ it 'uses special api url' do
+ stub_request(:get, 'https://apispecial.geoloqi.com/1/account/username').
+ with(:headers => {'Authorization'=>'OAuth access_token1234'}).
+ to_return(:body => {'username' => 'testuser'}.to_json)
+
+ Geoloqi.config :client_id => CLIENT_ID, :client_secret => CLIENT_SECRET, :api_url => 'https://apispecial.geoloqi.com'
+ resp = Geoloqi.get ACCESS_TOKEN, 'account/username'
+ resp[:username].must_equal 'testuser'
+ end
+
it 'displays log information if logger is provided' do
stub_request(:get, api_url('account/username?cats=lol')).
with(:headers => {'Authorization'=>'OAuth access_token1234'}).

0 comments on commit 9e3c136

Please sign in to comment.