Skip to content

Commit

Permalink
Merge pull request #46 from whichdigital/verbose-log-right-http-verb
Browse files Browse the repository at this point in the history
Fixing the issue #45 that was always verbosedebuging GET even
when another http verb was used.
  • Loading branch information
raul-gracia committed Apr 3, 2014
2 parents 44844af + 7230976 commit 5c38f7c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_rest_client/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def do_request(etag)
if verbose?
ActiveRestClient::Logger.debug "ActiveRestClient Verbose Log:"
ActiveRestClient::Logger.debug " Request"
ActiveRestClient::Logger.debug " >> GET #{@url} HTTP/1.1"
ActiveRestClient::Logger.debug " >> #{http_method.upcase} #{@url} HTTP/1.1"
http_headers.each do |k,v|
ActiveRestClient::Logger.debug " >> #{k} : #{v}"
end
Expand Down
14 changes: 14 additions & 0 deletions spec/lib/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class VerboseExampleClient < ExampleClient
base_url "http://www.example.com"
verbose!
get :all, "/all"
post :create, "/create"
end

class FilteredBodyExampleClient < ExampleClient
Expand Down Expand Up @@ -228,6 +229,19 @@ class FilteredBodyExampleClient < ExampleClient
object.create
end

it "should verbose debug the with the right http verb" do
ActiveRestClient::Connection.
any_instance.
should_receive(:post).
with("/create", "first_name=John&should_disappear=true", an_instance_of(Hash)).
and_return(OpenStruct.new(body:"{\"first_name\":\"John\", \"id\":1234}", headers:{}, status:200))
ActiveRestClient::Logger.should_receive(:debug).with(/ POST /)
ActiveRestClient::Logger.stub(:debug).with(any_args)

object = VerboseExampleClient.new(first_name:"John", should_disappear:true)
object.create
end

it "should verbose log if enabled" do
connection = double(ActiveRestClient::Connection).as_null_object
ActiveRestClient::ConnectionManager.should_receive(:get_connection).and_return(connection)
Expand Down

0 comments on commit 5c38f7c

Please sign in to comment.