Skip to content

Commit

Permalink
Merge pull request iamfmjk#50 from kytrinyx/simplify-basic-client
Browse files Browse the repository at this point in the history
Inline the Etsy.host parameter in BasicClient
  • Loading branch information
rogsmith committed Sep 1, 2012
2 parents a83e702 + e3afce3 commit 581f0f7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/etsy/basic_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class BasicClient

# Create a new client that will connect to the specified host
#
def initialize(host)
@host = host
def initialize
@host = Etsy.host
end

def client # :nodoc:
Expand Down
2 changes: 1 addition & 1 deletion lib/etsy/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def secure_client
end

def basic_client
BasicClient.new(Etsy.host)
BasicClient.new
end

def secure?
Expand Down
5 changes: 3 additions & 2 deletions test/unit/etsy/basic_client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ class BasicClientTest < Test::Unit::TestCase
context "An instance of the BasicClient class" do

should "be able to construct a client" do
client = BasicClient.new('example.com')
Etsy.stubs(:host).returns 'example.com'
client = BasicClient.new
Net::HTTP.stubs(:new).with('example.com').returns('client')

client.client.should == 'client'
Expand All @@ -16,7 +17,7 @@ class BasicClientTest < Test::Unit::TestCase
http_client = stub()
http_client.stubs(:get).with('endpoint').returns('response')

client = BasicClient.new('')
client = BasicClient.new
client.stubs(:client).returns(http_client)

client.get('endpoint').should == 'response'
Expand Down
6 changes: 2 additions & 4 deletions test/unit/etsy/request_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,8 @@ class RequestTest < Test::Unit::TestCase

should "know the client for read-only mode" do
Etsy.stubs(:access_mode).returns(:read_only)
Etsy.stubs(:host).returns('example.com')

BasicClient.stubs(:new).with('example.com').returns('client')
BasicClient.stubs(:new).returns 'client'

r = Request.new('')

Expand All @@ -143,9 +142,8 @@ class RequestTest < Test::Unit::TestCase

should "know the client for authenticated mode when there is no access token information" do
Etsy.stubs(:access_mode).returns(:authenticated)
Etsy.stubs(:host).returns('example.com')

BasicClient.stubs(:new).with('example.com').returns('client')
BasicClient.stubs(:new).returns 'client'

r = Request.new('')

Expand Down

0 comments on commit 581f0f7

Please sign in to comment.