spec/cfoundry/trace_helpers_spec.rb in cfoundry-0.4.21 vs spec/cfoundry/trace_helpers_spec.rb in cfoundry-0.5.0

- old
+ new

@@ -1,20 +1,26 @@ require 'spec_helper' describe CFoundry::TraceHelpers do let(:fake_class) { Class.new { include CFoundry::TraceHelpers } } - let(:request) { Net::HTTP::Get.new("http://api.cloudfoundry.com/foo", "bb-FOO" => "bar") } - let(:response) { Net::HTTPNotFound.new("foo", 404, "bar") } + let(:request) do + { + :method => "GET", + :url => "http://api.cloudfoundry.com/foo", + :headers => { "bb-foo" => "bar", "accept" => "*/*" } + } + end + let(:response) { { :status => 404, :body => "not found", :headers => {} } } shared_examples "request_trace tests" do it { should include request_trace } it { should include header_trace } it { should include body_trace } end shared_examples "response_trace tests" do - before { stub(response).body { response_body } } + before { response[:body] = response_body } it "traces the provided response" do fake_class.new.response_trace(response).should == response_trace end end @@ -31,11 +37,11 @@ end context "with a request body" do let(:body_trace) { "REQUEST_BODY: Some body text" } - before { request.body = "Some body text" } + before { request[:body] = "Some body text" } include_examples "request_trace tests" end it "returns nil if request is nil" do @@ -51,10 +57,9 @@ include_examples "response_trace tests" end context "with a JSON response body" do - let(:response_body) { "{\"name\": \"vcap\",\"build\": 2222,\"support\": \"http://support.cloudfoundry.com\"}" } let(:response_trace) { "RESPONSE: [404]\nRESPONSE_HEADERS:\n\nRESPONSE_BODY:\n#{MultiJson.dump(MultiJson.load(response_body), :pretty => true)}" } include_examples "response_trace tests" end \ No newline at end of file