Skip to content

Commit

Permalink
feat: update http client code
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Feb 10, 2019
1 parent 094e0fe commit bba3a08
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/pact/hal/http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ def raw_body
__getobj__().body
end

def status
code.to_i
end

def success?
__getobj__().code.start_with?("2")
end
Expand Down
12 changes: 12 additions & 0 deletions lib/pact/hal/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ def run(payload = nil)
end
end

def title_or_name
title || name
end

def title
@attrs['title']
end

def name
@attrs['name']
end

def get(payload = {}, headers = {})
wrap_response(href, @http_client.get(href, payload, headers))
end
Expand Down
3 changes: 1 addition & 2 deletions spec/lib/pact/hal/http_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
module Pact
module Hal
describe HttpClient do

before do
allow(Retry).to receive(:until_true) { |&block| block.call }
end

subject { HttpClient.new(username: 'foo', password: 'bar' ) }
subject { HttpClient.new(username: 'foo', password: 'bar') }

describe "get" do
let!(:request) do
Expand Down

0 comments on commit bba3a08

Please sign in to comment.