Skip to content

Commit

Permalink
Allow closing underlying connection. (#67)
Browse files Browse the repository at this point in the history
Fixes #66.
  • Loading branch information
ioquatix authored Apr 11, 2020
1 parent a541a68 commit 7d57eda
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/sawyer/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ def initialize(endpoint, options = nil)
yield @conn if block_given?
end

# Public: Close the underlying connection.
def close
@conn.close
end

# Public: Retains a reference to the root relations of the API.
#
# Returns a Sawyer::Relation::Map.
Expand Down
2 changes: 1 addition & 1 deletion sawyer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
spec.homepage = 'https://github.com/lostisland/sawyer'
spec.licenses = ['MIT']

spec.add_dependency 'faraday', ['> 0.8', '< 2.0']
spec.add_dependency 'faraday', "~> 1.0"
spec.add_dependency 'addressable', ['>= 2.3.5']

spec.files = %w(Gemfile LICENSE.md README.md Rakefile)
Expand Down
4 changes: 4 additions & 0 deletions test/agent_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def setup
end
end

def test_close
@agent.close
end

def test_accesses_root_relations
@stubs.get '/a/' do |env|
assert_equal 'foo.com', env[:url].host
Expand Down

0 comments on commit 7d57eda

Please sign in to comment.