spec/rack/contrib/content_hash_spec.rb in rack-content-hash-0.0.1 vs spec/rack/contrib/content_hash_spec.rb in rack-content-hash-0.0.2

- old
+ new

@@ -1,9 +1,10 @@ +require 'spec_helper' describe Rack::Contrib::ContentHash do - let (:response) { [200, {'Location' => 'lolwhat'}, 'foobar-body'] } - let (:response_clone) { [200, {'Location' => 'lolwhat'}, 'foobar-body'] } + let (:response) { [200, {'Location' => 'lolwhat'}, ['foobar', '-body']] } + let (:response_clone) { [200, {'Location' => 'lolwhat'}, ['foobar', '-body']] } describe "#initialize" do it "accepts an app" do expect { ware = Rack::Contrib::ContentHash.new nil }.not_to raise_error end @@ -37,9 +38,20 @@ it "returns the same data from the app" do app = double(nil, call: response) env = {} ware = Rack::Contrib::ContentHash.new app ware.call(env).should eq(response_clone) + end + + it "joins the body internally, but returns the array" do + body = response[2] + body.stub(join: "foobar-body") + + app = double(nil, call: response) + env = {} + ware = Rack::Contrib::ContentHash.new app + ware.call(env).should eq(response_clone) + body.should have_received(:join).with "" end end context "MD5 hashing is enabled" do it "hashes the body, and adds a Content-MD5 header" do