diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2ed702 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/rack-test-0.6.3.gem diff --git a/.rh-ror50-rubygem-rack-test.metadata b/.rh-ror50-rubygem-rack-test.metadata new file mode 100644 index 0000000..f88d56e --- /dev/null +++ b/.rh-ror50-rubygem-rack-test.metadata @@ -0,0 +1 @@ +6fd5a7f881a65ef93b66e21556ef67fbe08a2fcc SOURCES/rack-test-0.6.3.gem diff --git a/README.md b/README.md deleted file mode 100644 index 98f42b4..0000000 --- a/README.md +++ /dev/null @@ -1,4 +0,0 @@ -The master branch has no content - -Look at the c7 branch if you are working with CentOS-7, or the c4/c5/c6 branch for CentOS-4, 5 or 6 -If you find this file in a distro specific branch, it means that no content has been checked in yet diff --git a/SOURCES/rubygem-rack-test-0.6.3-Fix-test-for-RSpec-3.patch b/SOURCES/rubygem-rack-test-0.6.3-Fix-test-for-RSpec-3.patch new file mode 100644 index 0000000..909d516 --- /dev/null +++ b/SOURCES/rubygem-rack-test-0.6.3-Fix-test-for-RSpec-3.patch @@ -0,0 +1,1309 @@ +diff --git a/spec/rack/test/cookie_spec.rb b/spec/rack/test/cookie_spec.rb +index e4bce5a..e0839e5 100644 +--- a/spec/rack/test/cookie_spec.rb ++++ b/spec/rack/test/cookie_spec.rb +@@ -5,90 +5,88 @@ + context "cookies" do + it "keeps a cookie jar" do + get "/cookies/show" +- check last_request.cookies.should == {} ++ check expect(last_request.cookies).to eq({}) + + get "/cookies/set", "value" => "1" + get "/cookies/show" +- last_request.cookies.should == { "value" => "1" } ++ expect(last_request.cookies).to eq({ "value" => "1" }) + end + + it "doesn't send expired cookies" do + get "/cookies/set", "value" => "1" + now = Time.now +- Time.stub!(:now => now + 60) ++ allow(Time).to receive_messages(:now => now + 60) + get "/cookies/show" +- last_request.cookies.should == {} ++ expect(last_request.cookies).to eq({}) + end + + it "cookie path defaults to the uri of the document that was requested" do +- pending "See issue rack-test github issue #50" do +- post "/cookies/default-path", "value" => "cookie" +- get "/cookies/default-path" +- check last_request.cookies.should == { "simple"=>"cookie" } +- get "/cookies/show" +- check last_request.cookies.should == { } +- end ++ pending "See issue rack-test github issue #50" ++ post "/cookies/default-path", "value" => "cookie" ++ get "/cookies/default-path" ++ expect(last_request.cookies).to eq({ "simple"=>"cookie" }) ++ get "/cookies/show" ++ expect(last_request.cookies).to eq({}) + end + + it "escapes cookie values" do + jar = Rack::Test::CookieJar.new + jar["value"] = "foo;abc" +- jar["value"].should == "foo;abc" ++ expect(jar["value"]).to eq("foo;abc") + end + + it "deletes cookies directly from the CookieJar" do + jar = Rack::Test::CookieJar.new + jar["abcd"] = "1234" +- jar["abcd"].should == "1234" ++ expect(jar["abcd"]).to eq("1234") + jar.delete("abcd") +- jar["abcd"].should == nil ++ expect(jar["abcd"]).to eq(nil) + end + + it "doesn't send cookies with the wrong domain" do + get "http://www.example.com/cookies/set", "value" => "1" + get "http://www.other.example/cookies/show" +- last_request.cookies.should == {} ++ expect(last_request.cookies).to eq({}) + end + + it "doesn't send cookies with the wrong path" do + get "/cookies/set", "value" => "1" + get "/not-cookies/show" +- last_request.cookies.should == {} ++ expect(last_request.cookies).to eq({}) + end + + it "persists cookies across requests that don't return any cookie headers" do + get "/cookies/set", "value" => "1" + get "/void" + get "/cookies/show" +- last_request.cookies.should == { "value" => "1" } ++ expect(last_request.cookies).to eq({ "value" => "1" }) + end + + it "deletes cookies" do + get "/cookies/set", "value" => "1" + get "/cookies/delete" + get "/cookies/show" +- last_request.cookies.should == { } ++ expect(last_request.cookies).to eq({ }) + end + + it "respects cookie domains when no domain is explicitly set" do +- pending "FIXME: www.example.org should not get the first cookie" do +- request("http://example.org/cookies/count").should have_body("1") +- request("http://www.example.org/cookies/count").should have_body("1") +- request("http://example.org/cookies/count").should have_body("2") +- request("http://www.example.org/cookies/count").should have_body("2") +- end ++ pending "FIXME: www.example.org should not get the first cookie" ++ expect(request("http://example.org/cookies/count")).to have_body("1") ++ expect(request("http://www.example.org/cookies/count")).to have_body("1") ++ expect(request("http://example.org/cookies/count")).to have_body("2") ++ expect(request("http://www.example.org/cookies/count")).to have_body("2") + end + + it "treats domains case insensitively" do + get "http://example.com/cookies/set", "value" => "1" + get "http://EXAMPLE.COM/cookies/show" +- last_request.cookies.should == { "value" => "1" } ++ expect(last_request.cookies).to eq({ "value" => "1" }) + end + + it "treats paths case sensitively" do + get "/cookies/set", "value" => "1" + get "/COOKIES/show" +- last_request.cookies.should == {} ++ expect(last_request.cookies).to eq({}) + end + + it "prefers more specific cookies" do +@@ -96,124 +94,124 @@ + get "http://sub.example.com/cookies/set", "value" => "sub" + + get "http://sub.example.com/cookies/show" +- check last_request.cookies.should == { "value" => "sub" } ++ check expect(last_request.cookies).to eq({ "value" => "sub" }) + + get "http://example.com/cookies/show" +- last_request.cookies.should == { "value" => "domain" } ++ expect(last_request.cookies).to eq({ "value" => "domain" }) + end + + it "treats cookie names case insensitively" do + get "/cookies/set", "value" => "lowercase" + get "/cookies/set-uppercase", "value" => "UPPERCASE" + get "/cookies/show" +- last_request.cookies.should == { "VALUE" => "UPPERCASE" } ++ expect(last_request.cookies).to eq({ "VALUE" => "UPPERCASE" }) + end + + it "defaults the domain to the request domain" do + get "http://example.com/cookies/set-simple", "value" => "cookie" + get "http://example.com/cookies/show" +- check last_request.cookies.should == { "simple" => "cookie" } ++ check expect(last_request.cookies).to eq({ "simple" => "cookie" }) + + get "http://other.example/cookies/show" +- last_request.cookies.should == {} ++ expect(last_request.cookies).to eq({}) + end + + it "defaults the domain to the request path up to the last slash" do + get "/cookies/set-simple", "value" => "1" + get "/not-cookies/show" +- last_request.cookies.should == {} ++ expect(last_request.cookies).to eq({}) + end + + it "supports secure cookies" do + get "https://example.com/cookies/set-secure", "value" => "set" + get "http://example.com/cookies/show" +- check last_request.cookies.should == {} ++ check expect(last_request.cookies).to eq({}) + + get "https://example.com/cookies/show" +- last_request.cookies.should == { "secure-cookie" => "set" } +- rack_mock_session.cookie_jar['secure-cookie'].should == 'set' ++ expect(last_request.cookies).to eq({ "secure-cookie" => "set" }) ++ expect(rack_mock_session.cookie_jar['secure-cookie']).to eq('set') + end + + it "keeps separate cookie jars for different domains" do + get "http://example.com/cookies/set", "value" => "example" + get "http://example.com/cookies/show" +- check last_request.cookies.should == { "value" => "example" } ++ check expect(last_request.cookies).to eq({ "value" => "example" }) + + get "http://other.example/cookies/set", "value" => "other" + get "http://other.example/cookies/show" +- check last_request.cookies.should == { "value" => "other" } ++ check expect(last_request.cookies).to eq({ "value" => "other" }) + + get "http://example.com/cookies/show" +- last_request.cookies.should == { "value" => "example" } ++ expect(last_request.cookies).to eq({ "value" => "example" }) + end + + it "keeps one cookie jar for domain and its subdomains" do + get "http://example.org/cookies/subdomain" + get "http://example.org/cookies/subdomain" +- last_request.cookies.should == { "count" => "1" } ++ expect(last_request.cookies).to eq({ "count" => "1" }) + + get "http://foo.example.org/cookies/subdomain" +- last_request.cookies.should == { "count" => "2" } ++ expect(last_request.cookies).to eq({ "count" => "2" }) + end + + it "allows cookies to be cleared" do + get "/cookies/set", "value" => "1" + clear_cookies + get "/cookies/show" +- last_request.cookies.should == {} ++ expect(last_request.cookies).to eq({}) + end + + it "allow cookies to be set" do + set_cookie "value=10" + get "/cookies/show" +- last_request.cookies.should == { "value" => "10" } ++ expect(last_request.cookies).to eq({ "value" => "10" }) + end + + it "allows an array of cookies to be set" do + set_cookie ["value=10", "foo=bar"] + get "/cookies/show" +- last_request.cookies.should == { "value" => "10", "foo" => "bar" } ++ expect(last_request.cookies).to eq({ "value" => "10", "foo" => "bar" }) + end + + it "skips emtpy string cookies" do + set_cookie "value=10\n\nfoo=bar" + get "/cookies/show" +- last_request.cookies.should == { "value" => "10", "foo" => "bar" } ++ expect(last_request.cookies).to eq({ "value" => "10", "foo" => "bar" }) + end + + it "parses multiple cookies properly" do + get "/cookies/set-multiple" + get "/cookies/show" +- last_request.cookies.should == { "key1" => "value1", "key2" => "value2" } ++ expect(last_request.cookies).to eq({ "key1" => "value1", "key2" => "value2" }) + end + + it "supports multiple sessions" do + with_session(:first) do + get "/cookies/set", "value" => "1" + get "/cookies/show" +- last_request.cookies.should == { "value" => "1" } ++ expect(last_request.cookies).to eq({ "value" => "1" }) + end + + with_session(:second) do + get "/cookies/show" +- last_request.cookies.should == { } ++ expect(last_request.cookies).to eq({ }) + end + end + + it "uses :default as the default session name" do + get "/cookies/set", "value" => "1" + get "/cookies/show" +- check last_request.cookies.should == { "value" => "1" } ++ check expect(last_request.cookies).to eq({ "value" => "1" }) + + with_session(:default) do + get "/cookies/show" +- last_request.cookies.should == { "value" => "1" } ++ expect(last_request.cookies).to eq({ "value" => "1" }) + end + end + + it "accepts explicitly provided cookies" do + request "/cookies/show", :cookie => "value=1" +- last_request.cookies.should == { "value" => "1" } ++ expect(last_request.cookies).to eq({ "value" => "1" }) + end + end + end +diff --git a/spec/rack/test/digest_auth_spec.rb b/spec/rack/test/digest_auth_spec.rb +index 7b966e6..cccf1d6 100644 +--- a/spec/rack/test/digest_auth_spec.rb ++++ b/spec/rack/test/digest_auth_spec.rb +@@ -15,31 +15,31 @@ def app + it 'incorrectly authenticates GETs' do + digest_authorize 'foo', 'bar' + get '/' +- last_response.should be_challenge ++ expect(last_response).to be_challenge + end + + it "correctly authenticates GETs" do + digest_authorize "alice", "correct-password" + response = get "/" +- response.should be_ok ++ expect(response).to be_ok + end + + it "correctly authenticates GETs with params" do + digest_authorize "alice", "correct-password" + response = get "/", "foo" => "bar" +- response.should be_ok ++ expect(response).to be_ok + end + + it "correctly authenticates POSTs" do + digest_authorize "alice", "correct-password" + response = post "/" +- response.should be_ok ++ expect(response).to be_ok + end + + it "returns a re-challenge if authenticating incorrectly" do + digest_authorize "alice", "incorrect-password" + response = get "/" +- response.should be_challenge ++ expect(response).to be_challenge + end + + end +diff --git a/spec/rack/test/multipart_spec.rb b/spec/rack/test/multipart_spec.rb +index ad6c3ae..2e7bf16 100644 +--- a/spec/rack/test/multipart_spec.rb ++++ b/spec/rack/test/multipart_spec.rb +@@ -23,83 +23,83 @@ def second_uploaded_file + context "uploading a file" do + it "sends the multipart/form-data content type" do + post "/", "photo" => uploaded_file +- last_request.env["CONTENT_TYPE"].should include("multipart/form-data;") ++ expect(last_request.env["CONTENT_TYPE"]).to include("multipart/form-data;") + end + + it "sends regular params" do + post "/", "photo" => uploaded_file, "foo" => "bar" +- last_request.POST["foo"].should == "bar" ++ expect(last_request.POST["foo"]).to eq("bar") + end + + it "sends nested params" do + post "/", "photo" => uploaded_file, "foo" => {"bar" => "baz"} +- last_request.POST["foo"]["bar"].should == "baz" ++ expect(last_request.POST["foo"]["bar"]).to eq("baz") + end + + it "sends multiple nested params" do + post "/", "photo" => uploaded_file, "foo" => {"bar" => {"baz" => "bop"}} +- last_request.POST["foo"]["bar"]["baz"].should == "bop" ++ expect(last_request.POST["foo"]["bar"]["baz"]).to eq("bop") + end + + it "sends params with arrays" do + post "/", "photo" => uploaded_file, "foo" => ["1", "2"] +- last_request.POST["foo"].should == ["1", "2"] ++ expect(last_request.POST["foo"]).to eq(["1", "2"]) + end + + it "sends params with encoding sensitive values" do + post "/", "photo" => uploaded_file, "foo" => "bar? baz" +- last_request.POST["foo"].should == "bar? baz" ++ expect(last_request.POST["foo"]).to eq("bar? baz") + end + + it "sends params encoded as ISO-8859-1" do + post "/", "photo" => uploaded_file, "foo" => "bar", "utf8" => "☃" +- last_request.POST["foo"].should == "bar" ++ expect(last_request.POST["foo"]).to eq("bar") + + if Rack::Test.encoding_aware_strings? +- last_request.POST["utf8"].should == "☃" ++ expect(last_request.POST["utf8"]).to eq("☃") + else +- last_request.POST["utf8"].should == "\xE2\x98\x83" ++ expect(last_request.POST["utf8"]).to eq("\xE2\x98\x83") + end + end + + it "sends params with parens in names" do + post "/", "photo" => uploaded_file, "foo(1i)" => "bar" +- last_request.POST["foo(1i)"].should == "bar" ++ expect(last_request.POST["foo(1i)"]).to eq("bar") + end + + it "sends params with encoding sensitive names" do + post "/", "photo" => uploaded_file, "foo bar" => "baz" +- last_request.POST["foo bar"].should == "baz" ++ expect(last_request.POST["foo bar"]).to eq("baz") + end + + it "sends files with the filename" do + post "/", "photo" => uploaded_file +- last_request.POST["photo"][:filename].should == "foo.txt" ++ expect(last_request.POST["photo"][:filename]).to eq("foo.txt") + end + + it "sends files with the text/plain MIME type by default" do + post "/", "photo" => uploaded_file +- last_request.POST["photo"][:type].should == "text/plain" ++ expect(last_request.POST["photo"][:type]).to eq("text/plain") + end + + it "sends files with the right name" do + post "/", "photo" => uploaded_file +- last_request.POST["photo"][:name].should == "photo" ++ expect(last_request.POST["photo"][:name]).to eq("photo") + end + + it "allows overriding the content type" do + post "/", "photo" => Rack::Test::UploadedFile.new(test_file_path, "image/jpeg") +- last_request.POST["photo"][:type].should == "image/jpeg" ++ expect(last_request.POST["photo"][:type]).to eq("image/jpeg") + end + + it "sends files with a Content-Length in the header" do + post "/", "photo" => uploaded_file +- last_request.POST["photo"][:head].should include("Content-Length: 4") ++ expect(last_request.POST["photo"][:head]).to include("Content-Length: 4") + end + + it "sends files as Tempfiles" do + post "/", "photo" => uploaded_file +- last_request.POST["photo"][:tempfile].should be_a(::Tempfile) ++ expect(last_request.POST["photo"][:tempfile]).to be_a(::Tempfile) + end + end + +@@ -107,39 +107,39 @@ def second_uploaded_file + context "uploading two files" do + it "sends the multipart/form-data content type" do + post "/", "photos" => [uploaded_file, second_uploaded_file] +- last_request.env["CONTENT_TYPE"].should include("multipart/form-data;") ++ expect(last_request.env["CONTENT_TYPE"]).to include("multipart/form-data;") + end + + it "sends files with the filename" do + post "/", "photos" => [uploaded_file, second_uploaded_file] +- last_request.POST["photos"].collect{|photo| photo[:filename]}.should == ["foo.txt", "bar.txt"] ++ expect(last_request.POST["photos"].collect{|photo| photo[:filename]}).to eq(["foo.txt", "bar.txt"]) + end + + it "sends files with the text/plain MIME type by default" do + post "/", "photos" => [uploaded_file, second_uploaded_file] +- last_request.POST["photos"].collect{|photo| photo[:type]}.should == ["text/plain", "text/plain"] ++ expect(last_request.POST["photos"].collect{|photo| photo[:type]}).to eq(["text/plain", "text/plain"]) + end + + it "sends files with the right names" do + post "/", "photos" => [uploaded_file, second_uploaded_file] +- last_request.POST["photos"].all?{|photo| photo[:name].should == "photos[]" } ++ last_request.POST["photos"].all?{|photo| expect(photo[:name]).to eq("photos[]") } + end + + it "allows mixed content types" do + image_file = Rack::Test::UploadedFile.new(test_file_path, "image/jpeg") + + post "/", "photos" => [uploaded_file, image_file] +- last_request.POST["photos"].collect{|photo| photo[:type]}.should == ["text/plain", "image/jpeg"] ++ expect(last_request.POST["photos"].collect{|photo| photo[:type]}).to eq(["text/plain", "image/jpeg"]) + end + + it "sends files with a Content-Length in the header" do + post "/", "photos" => [uploaded_file, second_uploaded_file] +- last_request.POST["photos"].all?{|photo| photo[:head].should include("Content-Length: 4") } ++ last_request.POST["photos"].all?{|photo| expect(photo[:head]).to include("Content-Length: 4") } + end + + it "sends both files as Tempfiles" do + post "/", "photos" => [uploaded_file, second_uploaded_file] +- last_request.POST["photos"].all?{|photo| photo[:tempfile].should be_a(::Tempfile) } ++ last_request.POST["photos"].all?{|photo| expect(photo[:tempfile]).to be_a(::Tempfile) } + end + end + end +diff --git a/spec/rack/test/uploaded_file_spec.rb b/spec/rack/test/uploaded_file_spec.rb +index cde4856..5c1e462 100644 +--- a/spec/rack/test/uploaded_file_spec.rb ++++ b/spec/rack/test/uploaded_file_spec.rb +@@ -8,17 +8,22 @@ def test_file_path + it "responds to things that Tempfile responds to" do + uploaded_file = Rack::Test::UploadedFile.new(test_file_path) + +- uploaded_file.should respond_to(:close) +- uploaded_file.should respond_to(:close!) +- uploaded_file.should respond_to(:delete) +- uploaded_file.should respond_to(:length) +- uploaded_file.should respond_to(:open) +- uploaded_file.should respond_to(:path) +- uploaded_file.should respond_to(:size) +- uploaded_file.should respond_to(:unlink) +- uploaded_file.should respond_to(:read) +- uploaded_file.should respond_to(:original_filename) +- uploaded_file.should respond_to(:tempfile) # Allows calls to params[:file].tempfile ++ expect(uploaded_file).to respond_to(:close) ++ expect(uploaded_file).to respond_to(:close!) ++ expect(uploaded_file).to respond_to(:delete) ++ expect(uploaded_file).to respond_to(:length) ++ expect(uploaded_file).to respond_to(:open) ++ expect(uploaded_file).to respond_to(:path) ++ expect(uploaded_file).to respond_to(:size) ++ expect(uploaded_file).to respond_to(:unlink) ++ expect(uploaded_file).to respond_to(:read) ++ expect(uploaded_file).to respond_to(:original_filename) ++ expect(uploaded_file).to respond_to(:tempfile) # Allows calls to params[:file].tempfile + end + ++ it "creates Tempfiles with original file's extension" do ++ uploaded_file = Rack::Test::UploadedFile.new(test_file_path) ++ ++ expect(File.extname(uploaded_file.path)).to eq(".txt") ++ end + end +diff --git a/spec/rack/test/utils_spec.rb b/spec/rack/test/utils_spec.rb +index 4557c5b..b3d764d 100644 +--- a/spec/rack/test/utils_spec.rb ++++ b/spec/rack/test/utils_spec.rb +@@ -5,48 +5,48 @@ + + describe "build_nested_query" do + it "converts empty strings to =" do +- build_nested_query("").should == "=" ++ expect(build_nested_query("")).to eq("=") + end + + it "converts nil to an empty string" do +- build_nested_query(nil).should == "" ++ expect(build_nested_query(nil)).to eq("") + end + + it "converts hashes with nil values" do +- build_nested_query(:a => nil).should == "a" ++ expect(build_nested_query(:a => nil)).to eq("a") + end + + it "converts hashes" do +- build_nested_query(:a => 1).should == "a=1" ++ expect(build_nested_query(:a => 1)).to eq("a=1") + end + + it "converts hashes with multiple keys" do + hash = { :a => 1, :b => 2 } +- ["a=1&b=2", "b=2&a=1"].should include(build_nested_query(hash)) ++ expect(["a=1&b=2", "b=2&a=1"]).to include(build_nested_query(hash)) + end + + it "converts arrays with one element" do +- build_nested_query(:a => [1]).should == "a[]=1" ++ expect(build_nested_query(:a => [1])).to eq("a[]=1") + end + + it "converts arrays with multiple elements" do +- build_nested_query(:a => [1, 2]).should == "a[]=1&a[]=2" ++ expect(build_nested_query(:a => [1, 2])).to eq("a[]=1&a[]=2") + end + + it "converts arrays with brackets '[]' in the name" do +- build_nested_query("a[]" => [1, 2]).should == "a%5B%5D=1&a%5B%5D=2" ++ expect(build_nested_query("a[]" => [1, 2])).to eq("a%5B%5D=1&a%5B%5D=2") + end + + it "converts nested hashes" do +- build_nested_query(:a => { :b => 1 }).should == "a[b]=1" ++ expect(build_nested_query(:a => { :b => 1 })).to eq("a[b]=1") + end + + it "converts arrays nested in a hash" do +- build_nested_query(:a => { :b => [1, 2] }).should == "a[b][]=1&a[b][]=2" ++ expect(build_nested_query(:a => { :b => [1, 2] })).to eq("a[b][]=1&a[b][]=2") + end + + it "converts arrays of hashes" do +- build_nested_query(:a => [{ :b => 2}, { :c => 3}]).should == "a[][b]=2&a[][c]=3" ++ expect(build_nested_query(:a => [{ :b => 2}, { :c => 3}])).to eq("a[][b]=2&a[][c]=3") + end + end + +@@ -62,9 +62,9 @@ + } + env = Rack::MockRequest.env_for("/", options) + params = Rack::Multipart.parse_multipart(env) +- check params["submit-name"].should == "Larry" +- check params["files"][:filename].should == "foo.txt" +- params["files"][:tempfile].read.should == "bar\n" ++ check expect(params["submit-name"]).to eq("Larry") ++ check expect(params["files"][:filename]).to eq("foo.txt") ++ expect(params["files"][:tempfile].read).to eq("bar\n") + end + + it "builds multipart bodies from array of files" do +@@ -78,13 +78,13 @@ + } + env = Rack::MockRequest.env_for("/", options) + params = Rack::Multipart.parse_multipart(env) +- check params["submit-name"].should == "Larry" ++ check expect(params["submit-name"]).to eq("Larry") + +- check params["files"][0][:filename].should == "foo.txt" +- params["files"][0][:tempfile].read.should == "bar\n" ++ check expect(params["files"][0][:filename]).to eq("foo.txt") ++ expect(params["files"][0][:tempfile].read).to eq("bar\n") + +- check params["files"][1][:filename].should == "bar.txt" +- params["files"][1][:tempfile].read.should == "baz\n" ++ check expect(params["files"][1][:filename]).to eq("bar.txt") ++ expect(params["files"][1][:tempfile].read).to eq("baz\n") + end + + it "builds nested multipart bodies" do +@@ -98,10 +98,10 @@ + } + env = Rack::MockRequest.env_for("/", options) + params = Rack::Multipart.parse_multipart(env) +- check params["people"][0]["submit-name"].should == "Larry" +- check params["people"][0]["files"][:filename].should == "foo.txt" +- params["people"][0]["files"][:tempfile].read.should == "bar\n" +- check params["foo"].should == ["1", "2"] ++ check expect(params["people"][0]["submit-name"]).to eq("Larry") ++ check expect(params["people"][0]["files"][:filename]).to eq("foo.txt") ++ expect(params["people"][0]["files"][:tempfile].read).to eq("bar\n") ++ check expect(params["foo"]).to eq(["1", "2"]) + end + + it "builds nested multipart bodies with an array of hashes" do +@@ -115,9 +115,9 @@ + } + env = Rack::MockRequest.env_for("/", options) + params = Rack::Multipart.parse_multipart(env) +- check params["files"][:filename].should == "foo.txt" +- params["files"][:tempfile].read.should == "bar\n" +- check params["foo"].should == [{"id" => "1", "name" => "Dave"}, {"id" => "2", "name" => "Steve"}] ++ check expect(params["files"][:filename]).to eq("foo.txt") ++ expect(params["files"][:tempfile].read).to eq("bar\n") ++ check expect(params["foo"]).to eq([{"id" => "1", "name" => "Dave"}, {"id" => "2", "name" => "Steve"}]) + end + + it "builds nested multipart bodies with arbitrarily nested array of hashes" do +@@ -133,11 +133,11 @@ + } + env = Rack::MockRequest.env_for("/", options) + params = Rack::Multipart.parse_multipart(env) +- check params["files"][:filename].should == "foo.txt" +- params["files"][:tempfile].read.should == "bar\n" +- check params["foo"].should == {"bar" => [{"id" => "1", "name" => "Dave"}, ++ check expect(params["files"][:filename]).to eq("foo.txt") ++ expect(params["files"][:tempfile].read).to eq("bar\n") ++ check expect(params["foo"]).to eq({"bar" => [{"id" => "1", "name" => "Dave"}, + {"id" => "2", "name" => "Steve", "qux" => [{"id" => '3', "name" => 'mike'}, +- {"id" => '4', "name" => 'Joan'}]}]} ++ {"id" => '4', "name" => 'Joan'}]}]}) + end + + it 'does not break with params that look nested, but are not' do +@@ -151,10 +151,10 @@ + } + env = Rack::MockRequest.env_for("/", options) + params = Rack::Multipart.parse_multipart(env) +- check params["files"][0][:filename].should == "foo.txt" +- params["files"][0][:tempfile].read.should == "bar\n" +- check params["foo"][0].should == "1" +- check params["bar"][0].should == {"qux" => "2"} ++ check expect(params["files"][0][:filename]).to eq("foo.txt") ++ expect(params["files"][0][:tempfile].read).to eq("bar\n") ++ check expect(params["foo"][0]).to eq("1") ++ check expect(params["bar"][0]).to eq({"qux" => "2"}) + end + + it 'allows for nested files' do +@@ -169,21 +169,21 @@ + } + env = Rack::MockRequest.env_for("/", options) + params = Rack::Multipart.parse_multipart(env) +- check params["foo"][0]["id"].should == "1" +- check params["foo"][0]["data"][:filename].should == "foo.txt" +- params["foo"][0]["data"][:tempfile].read.should == "bar\n" +- check params["foo"][1].should == {"id" => "2", "data" => ["3", "4"]} ++ check expect(params["foo"][0]["id"]).to eq("1") ++ check expect(params["foo"][0]["data"][:filename]).to eq("foo.txt") ++ expect(params["foo"][0]["data"][:tempfile].read).to eq("bar\n") ++ check expect(params["foo"][1]).to eq({"id" => "2", "data" => ["3", "4"]}) + end + + it "returns nil if no UploadedFiles were used" do + data = build_multipart("people" => [{"submit-name" => "Larry", "files" => "contents"}]) +- data.should be_nil ++ expect(data).to be_nil + end + + it "raises ArgumentErrors if params is not a Hash" do +- lambda { ++ expect { + build_multipart("foo=bar") +- }.should raise_error(ArgumentError, "value must be a Hash") ++ }.to raise_error(ArgumentError, "value must be a Hash") + end + + def multipart_file(name) +diff --git a/spec/rack/test_spec.rb b/spec/rack/test_spec.rb +index ba862b2..a9e2136 100644 +--- a/spec/rack/test_spec.rb ++++ b/spec/rack/test_spec.rb +@@ -4,137 +4,142 @@ + describe "initialization" do + it "supports being initialized with a Rack::MockSession app" do + session = Rack::Test::Session.new(Rack::MockSession.new(app)) +- session.request("/").should be_ok ++ expect(session.request("/")).to be_ok + end + + it "supports being initialized with an app" do + session = Rack::Test::Session.new(app) +- session.request("/").should be_ok ++ expect(session.request("/")).to be_ok + end + end + + describe "#request" do + it "requests the URI using GET by default" do + request "/" +- last_request.should be_get +- last_response.should be_ok ++ expect(last_request).to be_get ++ expect(last_response).to be_ok + end + + it "returns a response" do +- request("/").should be_ok ++ expect(request("/")).to be_ok + end + + it "uses the provided env" do + request "/", "X-Foo" => "bar" +- last_request.env["X-Foo"].should == "bar" ++ expect(last_request.env["X-Foo"]).to eq("bar") + end + + it "allows HTTP_HOST to be set" do + request "/", "HTTP_HOST" => "www.example.ua" +- last_request.env['HTTP_HOST'].should == "www.example.ua" ++ expect(last_request.env['HTTP_HOST']).to eq("www.example.ua") + end + + it "sets HTTP_HOST with port for non-default ports" do + request "http://foo.com:8080" +- last_request.env["HTTP_HOST"].should == "foo.com:8080" ++ expect(last_request.env["HTTP_HOST"]).to eq("foo.com:8080") + request "https://foo.com:8443" +- last_request.env["HTTP_HOST"].should == "foo.com:8443" ++ expect(last_request.env["HTTP_HOST"]).to eq("foo.com:8443") + end + + it "sets HTTP_HOST without port for default ports" do + request "http://foo.com" +- last_request.env["HTTP_HOST"].should == "foo.com" ++ expect(last_request.env["HTTP_HOST"]).to eq("foo.com") + request "http://foo.com:80" +- last_request.env["HTTP_HOST"].should == "foo.com" ++ expect(last_request.env["HTTP_HOST"]).to eq("foo.com") + request "https://foo.com:443" +- last_request.env["HTTP_HOST"].should == "foo.com" ++ expect(last_request.env["HTTP_HOST"]).to eq("foo.com") + end + + it "defaults to GET" do + request "/" +- last_request.env["REQUEST_METHOD"].should == "GET" ++ expect(last_request.env["REQUEST_METHOD"]).to eq("GET") + end + + it "defaults the REMOTE_ADDR to 127.0.0.1" do + request "/" +- last_request.env["REMOTE_ADDR"].should == "127.0.0.1" ++ expect(last_request.env["REMOTE_ADDR"]).to eq("127.0.0.1") + end + + it "sets rack.test to true in the env" do + request "/" +- last_request.env["rack.test"].should == true ++ expect(last_request.env["rack.test"]).to eq(true) + end + + it "defaults to port 80" do + request "/" +- last_request.env["SERVER_PORT"].should == "80" ++ expect(last_request.env["SERVER_PORT"]).to eq("80") + end + + it "defaults to example.org" do + request "/" +- last_request.env["SERVER_NAME"].should == "example.org" ++ expect(last_request.env["SERVER_NAME"]).to eq("example.org") + end + + it "yields the response to a given block" do + request "/" do |response| +- response.should be_ok ++ expect(response).to be_ok + end + end + + it "supports sending :params" do + request "/", :params => { "foo" => "bar" } +- last_request.GET["foo"].should == "bar" ++ expect(last_request.GET["foo"]).to eq("bar") + end + + it "doesn't follow redirects by default" do + request "/redirect" +- last_response.should be_redirect +- last_response.body.should be_empty ++ expect(last_response).to be_redirect ++ expect(last_response.body).to be_empty + end + + it "allows passing :input in for POSTs" do + request "/", :method => :post, :input => "foo" +- last_request.env["rack.input"].read.should == "foo" ++ expect(last_request.env["rack.input"].read).to eq("foo") + end + + it "converts method names to a uppercase strings" do + request "/", :method => :put +- last_request.env["REQUEST_METHOD"].should == "PUT" ++ expect(last_request.env["REQUEST_METHOD"]).to eq("PUT") + end + + it "prepends a slash to the URI path" do + request "foo" +- last_request.env["PATH_INFO"].should == "/foo" ++ expect(last_request.env["PATH_INFO"]).to eq("/foo") + end + + it "accepts params and builds query strings for GET requests" do + request "/foo?baz=2", :params => {:foo => {:bar => "1"}} +- last_request.GET.should == { "baz" => "2", "foo" => { "bar" => "1" }} ++ expect(last_request.GET).to eq({ "baz" => "2", "foo" => { "bar" => "1" }}) + end + + it "parses query strings with repeated variable names correctly" do + request "/foo?bar=2&bar=3" +- last_request.GET.should == { "bar" => "3" } ++ expect(last_request.GET).to eq({ "bar" => "3" }) + end + + it "accepts raw input in params for GET requests" do + request "/foo?baz=2", :params => "foo[bar]=1" +- last_request.GET.should == { "baz" => "2", "foo" => { "bar" => "1" }} ++ expect(last_request.GET).to eq({ "baz" => "2", "foo" => { "bar" => "1" }}) + end + + it "does not rewrite a GET query string when :params is not supplied" do + request "/foo?a=1&b=2&c=3&e=4&d=5+%20" +- last_request.query_string.should == "a=1&b=2&c=3&e=4&d=5+%20" ++ expect(last_request.query_string).to eq("a=1&b=2&c=3&e=4&d=5+%20") ++ end ++ ++ it "does not overwrite multiple query string keys" do ++ request "/foo?a=1&a=2", :params => { :bar => 1 } ++ expect(last_request.query_string).to eq("a=1&a=2&bar=1") + end + + it "accepts params and builds url encoded params for POST requests" do + request "/foo", :method => :post, :params => {:foo => {:bar => "1"}} +- last_request.env["rack.input"].read.should == "foo[bar]=1" ++ expect(last_request.env["rack.input"].read).to eq("foo[bar]=1") + end + + it "accepts raw input in params for POST requests" do + request "/foo", :method => :post, :params => "foo[bar]=1" +- last_request.env["rack.input"].read.should == "foo[bar]=1" ++ expect(last_request.env["rack.input"].read).to eq("foo[bar]=1") + end + + context "when the response body responds_to?(:close)" do +@@ -155,7 +160,7 @@ def close + + it "closes response's body" do + body = CloseableBody.new +- body.should_receive(:close) ++ expect(body).to receive(:close) + + app = lambda do |env| + [200, {"Content-Type" => "text/html", "Content-Length" => "13"}, body] +@@ -172,65 +177,65 @@ def close + + session = Rack::Test::Session.new(Rack::MockSession.new(app)) + session.request("/") +- session.last_response.body.should == "Hello, World!" ++ expect(session.last_response.body).to eq("Hello, World!") + end + end + + context "when input is given" do + it "sends the input" do + request "/", :method => "POST", :input => "foo" +- last_request.env["rack.input"].read.should == "foo" ++ expect(last_request.env["rack.input"].read).to eq("foo") + end + + it "does not send a multipart request" do + request "/", :method => "POST", :input => "foo" +- last_request.env["CONTENT_TYPE"].should_not == "application/x-www-form-urlencoded" ++ expect(last_request.env["CONTENT_TYPE"]).not_to eq("application/x-www-form-urlencoded") + end + end + + context "for a POST specified with :method" do + it "uses application/x-www-form-urlencoded as the CONTENT_TYPE" do + request "/", :method => "POST" +- last_request.env["CONTENT_TYPE"].should == "application/x-www-form-urlencoded" ++ expect(last_request.env["CONTENT_TYPE"]).to eq("application/x-www-form-urlencoded") + end + end + + context "for a POST specified with REQUEST_METHOD" do + it "uses application/x-www-form-urlencoded as the CONTENT_TYPE" do + request "/", "REQUEST_METHOD" => "POST" +- last_request.env["CONTENT_TYPE"].should == "application/x-www-form-urlencoded" ++ expect(last_request.env["CONTENT_TYPE"]).to eq("application/x-www-form-urlencoded") + end + end + + context "when CONTENT_TYPE is specified in the env" do + it "does not overwrite the CONTENT_TYPE" do + request "/", "CONTENT_TYPE" => "application/xml" +- last_request.env["CONTENT_TYPE"].should == "application/xml" ++ expect(last_request.env["CONTENT_TYPE"]).to eq("application/xml") + end + end + + context "when the URL is https://" do + it "sets rack.url_scheme to https" do + get "https://example.org/" +- last_request.env["rack.url_scheme"].should == "https" ++ expect(last_request.env["rack.url_scheme"]).to eq("https") + end + + it "sets SERVER_PORT to 443" do + get "https://example.org/" +- last_request.env["SERVER_PORT"].should == "443" ++ expect(last_request.env["SERVER_PORT"]).to eq("443") + end + + it "sets HTTPS to on" do + get "https://example.org/" +- last_request.env["HTTPS"].should == "on" ++ expect(last_request.env["HTTPS"]).to eq("on") + end + end + + context "for a XHR" do + it "sends XMLHttpRequest for the X-Requested-With header" do + request "/", :xhr => true +- last_request.env["HTTP_X_REQUESTED_WITH"].should == "XMLHttpRequest" +- last_request.should be_xhr ++ expect(last_request.env["HTTP_X_REQUESTED_WITH"]).to eq("XMLHttpRequest") ++ expect(last_request).to be_xhr + end + end + end +@@ -240,21 +245,21 @@ def close + header "User-Agent", "Firefox" + request "/" + +- last_request.env["HTTP_USER_AGENT"].should == "Firefox" ++ expect(last_request.env["HTTP_USER_AGENT"]).to eq("Firefox") + end + + it "sets a Content-Type to be sent with requests" do + header "Content-Type", "application/json" + request "/" + +- last_request.env["CONTENT_TYPE"].should == "application/json" ++ expect(last_request.env["CONTENT_TYPE"]).to eq("application/json") + end + + it "sets a Host to be sent with requests" do + header "Host", "www.example.ua" + request "/" + +- last_request.env["HTTP_HOST"].should == "www.example.ua" ++ expect(last_request.env["HTTP_HOST"]).to eq("www.example.ua") + end + + it "persists across multiple requests" do +@@ -262,7 +267,7 @@ def close + request "/" + request "/" + +- last_request.env["HTTP_USER_AGENT"].should == "Firefox" ++ expect(last_request.env["HTTP_USER_AGENT"]).to eq("Firefox") + end + + it "overwrites previously set headers" do +@@ -270,7 +275,7 @@ def close + header "User-Agent", "Safari" + request "/" + +- last_request.env["HTTP_USER_AGENT"].should == "Safari" ++ expect(last_request.env["HTTP_USER_AGENT"]).to eq("Safari") + end + + it "can be used to clear a header" do +@@ -278,14 +283,14 @@ def close + header "User-Agent", nil + request "/" + +- last_request.env.should_not have_key("HTTP_USER_AGENT") ++ expect(last_request.env).not_to have_key("HTTP_USER_AGENT") + end + + it "is overridden by headers sent during the request" do + header "User-Agent", "Firefox" + request "/", "HTTP_USER_AGENT" => "Safari" + +- last_request.env["HTTP_USER_AGENT"].should == "Safari" ++ expect(last_request.env["HTTP_USER_AGENT"]).to eq("Safari") + end + end + +@@ -294,7 +299,7 @@ def close + env "rack.session", {:csrf => 'token'} + request "/" + +- last_request.env["rack.session"].should == {:csrf => 'token'} ++ expect(last_request.env["rack.session"]).to eq({:csrf => 'token'}) + end + + it "persists across multiple requests" do +@@ -302,7 +307,7 @@ def close + request "/" + request "/" + +- last_request.env["rack.session"].should == {:csrf => 'token'} ++ expect(last_request.env["rack.session"]).to eq({:csrf => 'token'}) + end + + it "overwrites previously set envs" do +@@ -310,7 +315,7 @@ def close + env "rack.session", {:some => :thing} + request "/" + +- last_request.env["rack.session"].should == {:some => :thing} ++ expect(last_request.env["rack.session"]).to eq({:some => :thing}) + end + + it "can be used to clear a env" do +@@ -318,14 +323,14 @@ def close + env "rack.session", nil + request "/" + +- last_request.env.should_not have_key("X_CSRF_TOKEN") ++ expect(last_request.env).not_to have_key("X_CSRF_TOKEN") + end + + it "is overridden by envs sent during the request" do + env "rack.session", {:csrf => 'token'} + request "/", "rack.session" => {:some => :thing} + +- last_request.env["rack.session"].should == {:some => :thing} ++ expect(last_request.env["rack.session"]).to eq({:some => :thing}) + end + end + +@@ -334,7 +339,7 @@ def close + authorize "bryan", "secret" + request "/" + +- last_request.env["HTTP_AUTHORIZATION"].should == "Basic YnJ5YW46c2VjcmV0\n" ++ expect(last_request.env["HTTP_AUTHORIZATION"]).to eq("Basic YnJ5YW46c2VjcmV0\n") + end + + it "includes the header for subsequent requests" do +@@ -342,7 +347,7 @@ def close + request "/" + request "/" + +- last_request.env["HTTP_AUTHORIZATION"].should == "Basic YnJ5YW46c2VjcmV0\n" ++ expect(last_request.env["HTTP_AUTHORIZATION"]).to eq("Basic YnJ5YW46c2VjcmV0\n") + end + end + +@@ -351,56 +356,56 @@ def close + get "/redirect" + follow_redirect! + +- last_response.should_not be_redirect +- last_response.body.should == "You've been redirected" +- last_request.env["HTTP_REFERER"].should eql("http://example.org/redirect") ++ expect(last_response).not_to be_redirect ++ expect(last_response.body).to eq("You've been redirected") ++ expect(last_request.env["HTTP_REFERER"]).to eql("http://example.org/redirect") + end + + it "does not include params when following the redirect" do + get "/redirect", { "foo" => "bar" } + follow_redirect! + +- last_request.GET.should == {} ++ expect(last_request.GET).to eq({}) + end + + it "raises an error if the last_response is not set" do +- lambda { ++ expect { + follow_redirect! +- }.should raise_error(Rack::Test::Error) ++ }.to raise_error(Rack::Test::Error) + end + + it "raises an error if the last_response is not a redirect" do + get "/" + +- lambda { ++ expect { + follow_redirect! +- }.should raise_error(Rack::Test::Error) ++ }.to raise_error(Rack::Test::Error) + end + end + + describe "#last_request" do + it "returns the most recent request" do + request "/" +- last_request.env["PATH_INFO"].should == "/" ++ expect(last_request.env["PATH_INFO"]).to eq("/") + end + + it "raises an error if no requests have been issued" do +- lambda { ++ expect { + last_request +- }.should raise_error(Rack::Test::Error) ++ }.to raise_error(Rack::Test::Error) + end + end + + describe "#last_response" do + it "returns the most recent response" do + request "/" +- last_response["Content-Type"].should == "text/html;charset=utf-8" ++ expect(last_response["Content-Type"]).to eq("text/html;charset=utf-8") + end + + it "raises an error if no requests have been issued" do +- lambda { ++ expect { + last_response +- }.should raise_error ++ }.to raise_error(Rack::Test::Error) + end + end + +@@ -413,7 +418,7 @@ def close + end + + get "/" +- ran.should == true ++ expect(ran).to eq(true) + end + + it "runs multiple callbacks" do +@@ -426,7 +431,7 @@ def close + end + + get "/" +- count.should == 2 ++ expect(count).to eq(2) + end + end + +@@ -439,27 +444,27 @@ def verb + + it "uses the provided params hash" do + get "/", :foo => "bar" +- last_request.GET.should == { "foo" => "bar" } ++ expect(last_request.GET).to eq({ "foo" => "bar" }) + end + + it "sends params with parens in names" do + get "/", "foo(1i)" => "bar" +- last_request.GET["foo(1i)"].should == "bar" ++ expect(last_request.GET["foo(1i)"]).to eq("bar") + end + + it "supports params with encoding sensitive names" do + get "/", "foo bar" => "baz" +- last_request.GET["foo bar"].should == "baz" ++ expect(last_request.GET["foo bar"]).to eq("baz") + end + + it "supports params with nested encoding sensitive names" do + get "/", "boo" => {"foo bar" => "baz"} +- last_request.GET.should == {"boo" => {"foo bar" => "baz"}} ++ expect(last_request.GET).to eq({"boo" => {"foo bar" => "baz"}}) + end + + it "accepts params in the path" do + get "/?foo=bar" +- last_request.GET.should == { "foo" => "bar" } ++ expect(last_request.GET).to eq({ "foo" => "bar" }) + end + end + +@@ -480,28 +485,28 @@ def verb + + it "uses the provided params hash" do + post "/", :foo => "bar" +- last_request.POST.should == { "foo" => "bar" } ++ expect(last_request.POST).to eq({ "foo" => "bar" }) + end + + it "supports params with encoding sensitive names" do + post "/", "foo bar" => "baz" +- last_request.POST["foo bar"].should == "baz" ++ expect(last_request.POST["foo bar"]).to eq("baz") + end + + it "uses application/x-www-form-urlencoded as the CONTENT_TYPE" do + post "/" +- last_request.env["CONTENT_TYPE"].should == "application/x-www-form-urlencoded" ++ expect(last_request.env["CONTENT_TYPE"]).to eq("application/x-www-form-urlencoded") + end + + it "accepts a body" do + post "/", "Lobsterlicious!" +- last_request.body.read.should == "Lobsterlicious!" ++ expect(last_request.body.read).to eq("Lobsterlicious!") + end + + context "when CONTENT_TYPE is specified in the env" do + it "does not overwrite the CONTENT_TYPE" do + post "/", {}, { "CONTENT_TYPE" => "application/xml" } +- last_request.env["CONTENT_TYPE"].should == "application/xml" ++ expect(last_request.env["CONTENT_TYPE"]).to eq("application/xml") + end + end + end +@@ -515,7 +520,7 @@ def verb + + it "accepts a body" do + put "/", "Lobsterlicious!" +- last_request.body.read.should == "Lobsterlicious!" ++ expect(last_request.body.read).to eq("Lobsterlicious!") + end + end + +@@ -528,7 +533,7 @@ def verb + + it "accepts a body" do + patch "/", "Lobsterlicious!" +- last_request.body.read.should == "Lobsterlicious!" ++ expect(last_request.body.read).to eq("Lobsterlicious!") + end + end + +diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb +index 0666c42..de84ddf 100644 +--- a/spec/spec_helper.rb ++++ b/spec/spec_helper.rb +@@ -29,41 +29,41 @@ def check(*args) + it "requests the URL using VERB" do + send(verb, "/") + +- check last_request.env["REQUEST_METHOD"].should == verb.upcase +- last_response.should be_ok ++ check expect(last_request.env["REQUEST_METHOD"]).to eq(verb.upcase) ++ expect(last_response).to be_ok + end + + it "uses the provided env" do + send(verb, "/", {}, { "HTTP_USER_AGENT" => "Rack::Test" }) +- last_request.env["HTTP_USER_AGENT"].should == "Rack::Test" ++ expect(last_request.env["HTTP_USER_AGENT"]).to eq("Rack::Test") + end + + it "yields the response to a given block" do + yielded = false + + send(verb, "/") do |response| +- response.should be_ok ++ expect(response).to be_ok + yielded = true + end + +- yielded.should be_true ++ expect(yielded).to be_truthy + end + + it "sets the HTTP_HOST header with port" do + send(verb, "http://example.org:8080/uri") +- last_request.env["HTTP_HOST"].should == "example.org:8080" ++ expect(last_request.env["HTTP_HOST"]).to eq("example.org:8080") + end + + it "sets the HTTP_HOST header without port" do + send(verb, "/uri") +- last_request.env["HTTP_HOST"].should == "example.org" ++ expect(last_request.env["HTTP_HOST"]).to eq("example.org") + end + + context "for a XHR" do + it "sends XMLHttpRequest for the X-Requested-With header" do + send(verb, "/", {}, { :xhr => true }) +- last_request.env["HTTP_X_REQUESTED_WITH"].should == "XMLHttpRequest" +- last_request.should be_xhr ++ expect(last_request.env["HTTP_X_REQUESTED_WITH"]).to eq("XMLHttpRequest") ++ expect(last_request).to be_xhr + end + end + end +diff --git a/spec/support/matchers/body.rb b/spec/support/matchers/body.rb +index 0c83348..a79c1ff 100644 +--- a/spec/support/matchers/body.rb ++++ b/spec/support/matchers/body.rb +@@ -1,6 +1,6 @@ + RSpec::Matchers.define :have_body do |expected| + match do |response| +- response.body.should == expected ++ expect(response.body).to eq(expected) + end + + description do diff --git a/SOURCES/rubygem-rack-test-0.6.3-Fix-test-suite-for-Rack-2.x-compatiblity.patch b/SOURCES/rubygem-rack-test-0.6.3-Fix-test-suite-for-Rack-2.x-compatiblity.patch new file mode 100644 index 0000000..29a7d9c --- /dev/null +++ b/SOURCES/rubygem-rack-test-0.6.3-Fix-test-suite-for-Rack-2.x-compatiblity.patch @@ -0,0 +1,79 @@ +From d3e32e0ef2539a6e6c79022ee63807317074fb4f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?V=C3=ADt=20Ondruch?= +Date: Fri, 2 Sep 2016 12:25:29 +0200 +Subject: [PATCH] Fix test suite for Rack 2.x compatiblity. + +--- + spec/rack/test/utils_spec.rb | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/spec/rack/test/utils_spec.rb b/spec/rack/test/utils_spec.rb +index 3b27767..4557c5b 100644 +--- a/spec/rack/test/utils_spec.rb ++++ b/spec/rack/test/utils_spec.rb +@@ -61,7 +61,7 @@ describe Rack::Test::Utils do + :input => StringIO.new(data) + } + env = Rack::MockRequest.env_for("/", options) +- params = Rack::Utils::Multipart.parse_multipart(env) ++ params = Rack::Multipart.parse_multipart(env) + check params["submit-name"].should == "Larry" + check params["files"][:filename].should == "foo.txt" + params["files"][:tempfile].read.should == "bar\n" +@@ -77,7 +77,7 @@ describe Rack::Test::Utils do + :input => StringIO.new(data) + } + env = Rack::MockRequest.env_for("/", options) +- params = Rack::Utils::Multipart.parse_multipart(env) ++ params = Rack::Multipart.parse_multipart(env) + check params["submit-name"].should == "Larry" + + check params["files"][0][:filename].should == "foo.txt" +@@ -97,7 +97,7 @@ describe Rack::Test::Utils do + :input => StringIO.new(data) + } + env = Rack::MockRequest.env_for("/", options) +- params = Rack::Utils::Multipart.parse_multipart(env) ++ params = Rack::Multipart.parse_multipart(env) + check params["people"][0]["submit-name"].should == "Larry" + check params["people"][0]["files"][:filename].should == "foo.txt" + params["people"][0]["files"][:tempfile].read.should == "bar\n" +@@ -114,7 +114,7 @@ describe Rack::Test::Utils do + :input => StringIO.new(data) + } + env = Rack::MockRequest.env_for("/", options) +- params = Rack::Utils::Multipart.parse_multipart(env) ++ params = Rack::Multipart.parse_multipart(env) + check params["files"][:filename].should == "foo.txt" + params["files"][:tempfile].read.should == "bar\n" + check params["foo"].should == [{"id" => "1", "name" => "Dave"}, {"id" => "2", "name" => "Steve"}] +@@ -132,7 +132,7 @@ describe Rack::Test::Utils do + :input => StringIO.new(data) + } + env = Rack::MockRequest.env_for("/", options) +- params = Rack::Utils::Multipart.parse_multipart(env) ++ params = Rack::Multipart.parse_multipart(env) + check params["files"][:filename].should == "foo.txt" + params["files"][:tempfile].read.should == "bar\n" + check params["foo"].should == {"bar" => [{"id" => "1", "name" => "Dave"}, +@@ -150,7 +150,7 @@ describe Rack::Test::Utils do + :input => StringIO.new(data) + } + env = Rack::MockRequest.env_for("/", options) +- params = Rack::Utils::Multipart.parse_multipart(env) ++ params = Rack::Multipart.parse_multipart(env) + check params["files"][0][:filename].should == "foo.txt" + params["files"][0][:tempfile].read.should == "bar\n" + check params["foo"][0].should == "1" +@@ -168,7 +168,7 @@ describe Rack::Test::Utils do + :input => StringIO.new(data) + } + env = Rack::MockRequest.env_for("/", options) +- params = Rack::Utils::Multipart.parse_multipart(env) ++ params = Rack::Multipart.parse_multipart(env) + check params["foo"][0]["id"].should == "1" + check params["foo"][0]["data"][:filename].should == "foo.txt" + params["foo"][0]["data"][:tempfile].read.should == "bar\n" +-- +2.9.3 + diff --git a/SOURCES/rubygem-rack-test-0.6.3-Fix-test-uploaded-file.patch b/SOURCES/rubygem-rack-test-0.6.3-Fix-test-uploaded-file.patch new file mode 100644 index 0000000..1eea204 --- /dev/null +++ b/SOURCES/rubygem-rack-test-0.6.3-Fix-test-uploaded-file.patch @@ -0,0 +1,28 @@ +From fff392abc59c15427bec9105eb5f0f0bbda6cff9 Mon Sep 17 00:00:00 2001 +From: Raf Szalanski +Date: Thu, 2 Jul 2015 22:31:40 +0000 +Subject: [PATCH] Fix creation of tempfiles in Rack::Test::UploadedFile + +Tempfile's initializer is not very intuitive. If you want your tempfile +to have an extension you have to pass an array with two elements: + - basename + - extension (with a dot at the beginning) + +This change makes it behave more like original Rack::Multipart::UploadedFile. +--- + lib/rack/test/uploaded_file.rb | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/rack/test/uploaded_file.rb b/lib/rack/test/uploaded_file.rb +index d0d3e2a..3339412 100644 +--- a/lib/rack/test/uploaded_file.rb ++++ b/lib/rack/test/uploaded_file.rb +@@ -26,7 +26,7 @@ def initialize(path, content_type = "text/plain", binary = false) + @content_type = content_type + @original_filename = ::File.basename(path) + +- @tempfile = Tempfile.new(@original_filename) ++ @tempfile = Tempfile.new([@original_filename, ::File.extname(path)]) + @tempfile.set_encoding(Encoding::BINARY) if @tempfile.respond_to?(:set_encoding) + @tempfile.binmode if binary + diff --git a/SOURCES/rubygem-rack-test-0.6.3-Fix-test-uri.query.patch b/SOURCES/rubygem-rack-test-0.6.3-Fix-test-uri.query.patch new file mode 100644 index 0000000..6957640 --- /dev/null +++ b/SOURCES/rubygem-rack-test-0.6.3-Fix-test-uri.query.patch @@ -0,0 +1,41 @@ +From aeecb1809f82f6793b4c406115ce7b6e1e90bde1 Mon Sep 17 00:00:00 2001 +From: Adam Tanner +Date: Fri, 15 Mar 2013 16:01:48 -0400 +Subject: [PATCH] Don't clobber uri.query when it's present. + +--- + lib/rack/test.rb | 4 ++-- + spec/rack/test_spec.rb | 5 +++++ + 2 files changed, 7 insertions(+), 2 deletions(-) + +diff --git a/lib/rack/test.rb b/lib/rack/test.rb +index 8877e7f..e33bf1b 100644 +--- a/lib/rack/test.rb ++++ b/lib/rack/test.rb +@@ -209,8 +209,8 @@ def env_for(path, env) + # merge :params with the query string + if params = env[:params] + params = parse_nested_query(params) if params.is_a?(String) +- params.update(parse_nested_query(uri.query)) +- uri.query = build_nested_query(params) ++ ++ uri.query = [uri.query, build_nested_query(params)].compact.join("&") + end + elsif !env.has_key?(:input) + env["CONTENT_TYPE"] ||= "application/x-www-form-urlencoded" +diff --git a/spec/rack/test_spec.rb b/spec/rack/test_spec.rb +index a9e2136..c60b2cd 100644 +--- a/spec/rack/test_spec.rb ++++ b/spec/rack/test_spec.rb +@@ -132,6 +132,11 @@ + expect(last_request.query_string).to eq("a=1&a=2&bar=1") + end + ++ it "does not overwrite multiple query string keys" do ++ request "/foo?a=1&a=2", :params => { :bar => 1 } ++ last_request.query_string.should == "a=1&a=2&bar=1" ++ end ++ + it "accepts params and builds url encoded params for POST requests" do + request "/foo", :method => :post, :params => {:foo => {:bar => "1"}} + expect(last_request.env["rack.input"].read).to eq("foo[bar]=1") diff --git a/SPECS/rubygem-rack-test.spec b/SPECS/rubygem-rack-test.spec new file mode 100644 index 0000000..9fd418f --- /dev/null +++ b/SPECS/rubygem-rack-test.spec @@ -0,0 +1,174 @@ +%{?scl:%scl_package rubygem-%{gem_name}} +%{!?scl:%global pkg_name %{name}} + +%global gem_name rack-test + +%{?_with_bootstrap: %global bootstrap 1} + +Summary: Simple testing API built on Rack +Name: %{?scl_prefix}rubygem-%{gem_name} +Version: 0.6.3 +Release: 5%{?dist} +Group: Development/Languages +License: MIT +URL: http://gitrdoc.com/brynary/rack-test/tree/master +Source0: http://gems.rubyforge.org/gems/%{gem_name}-%{version}.gem +# Fix test errors caused by Rack 2.x changes. +# https://github.com/brynary/rack-test/pull/148 +Patch0: rubygem-rack-test-0.6.3-Fix-test-suite-for-Rack-2.x-compatiblity.patch +# Fix test for RSpec 3. +# https://github.com/brynary/rack-test/pull/134 +Patch1: rubygem-rack-test-0.6.3-Fix-test-for-RSpec-3.patch +# Fix test for uri.query +# https://github.com/brynary/rack-test/commit/4a4b2c1 +Patch2: rubygem-rack-test-0.6.3-Fix-test-uri.query.patch +# Fix test for uploaded file. +# https://github.com/brynary/rack-test/commit/5f78451 +Patch3: rubygem-rack-test-0.6.3-Fix-test-uploaded-file.patch + +Requires: %{?scl_prefix_ruby}ruby(release) +Requires: %{?scl_prefix_ruby}ruby(rubygems) +Requires: %{?scl_prefix}rubygem(rack) >= 1.0 +BuildRequires: %{?scl_prefix_ruby}rubygems-devel +BuildRequires: %{?scl_prefix}rubygem(rack) >= 1.0.0 +BuildRequires: %{?scl_prefix}rubygem(rspec) +%if ! 0%{?bootstrap} +BuildRequires: %{?scl_prefix}rubygem(sinatra) +%endif +BuildArch: noarch +Provides: %{?scl_prefix}rubygem(%{gem_name}) = %{version} + +# Explicitly require runtime subpackage, as long as older scl-utils do not generate it +%{?scl:Requires: %{?scl_prefix}runtime} + +%description +Rack::Test is a small, simple testing API for Rack apps. It can be used on its +own or as a reusable starting point for Web frameworks and testing libraries +to build on. Most of its initial functionality is an extraction of Merb 1.0's +request helpers feature. + +%package doc +Summary: Documentation for %{pkg_name} +Group: Documentation +Requires: %{?scl_prefix}%{pkg_name} = %{version}-%{release} +BuildArch: noarch + +%description doc +Documentation for %{pkg_name} + +%prep +%setup -n %{pkg_name}-%{version} -q -c -T +%{?scl:scl enable %{scl} - << \EOF} +%gem_install -n %{SOURCE0} +%{?scl:EOF} + +pushd .%{gem_instdir} +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +popd + +%build + +%install +mkdir -p %{buildroot}%{gem_dir} +cp -pa .%{gem_dir}/* \ + %{buildroot}%{gem_dir}/ + +%check +%if ! 0%{?bootstrap} +pushd .%{gem_instdir} +# We don't care about code coverage. +sed -i '/[cC]ode[cC]/ s/^/#/' spec/spec_helper.rb + +sed -i '/require "bundler\/setup"/d' spec/spec_helper.rb +%{?scl:scl enable %{scl} - << \EOF} +LANG="en_US.UTF-8" rspec spec +%{?scl:EOF} +popd +%endif + +%files +%dir %{gem_instdir} +%exclude %{gem_instdir}/.* +%{gem_libdir} +%doc %{gem_instdir}/MIT-LICENSE.txt +%exclude %{gem_cache} +%{gem_spec} + +%files doc +%doc %{gem_docdir} +%doc %{gem_instdir}/README.rdoc +%doc %{gem_instdir}/MIT-LICENSE.txt +%doc %{gem_instdir}/History.txt +%{gem_instdir}/Gemfile* +%{gem_instdir}/Thorfile +%{gem_instdir}/%{gem_name}.gemspec +%{gem_instdir}/spec +%{gem_instdir}/Rakefile + +%changelog +* Thu Oct 20 2016 Jun Aruga - 0.6.3-5 +- Fix test suite for Rack 2.x compatibilty. +- Fix test suite for Rspec 3 + +* Wed Feb 24 2016 Pavel Valena - 0.6.3-4 +- Update to 0.6.3 + +* Fri Jan 16 2015 Josef Stribny - 0.6.2-2 +- rebuilt for ror41 +- update URLs + +* Mon Oct 14 2013 Josef Stribny - 0.6.2-1 +- Update to 0.6.2 + +* Thu Jun 13 2013 Josef Stribny - 0.6.1-4 +- Rebuild for https://fedoraproject.org/wiki/Features/Ruby_2.0.0 + +* Wed Feb 27 2013 Vít Ondruch - 0.6.1-3 +- Rebuild to fix documentation vulnerability due to CVE-2013-0256. + +* Wed Jul 25 2012 Bohuslav Kabrda - 0.6.1-2 +- Specfile cleanup + +* Mon Apr 02 2012 Bohuslav Kabrda - 0.6.1-1 +- Rebuilt for scl. +- Updated to 0.6.1. + +* Tue Jan 24 2012 Bohuslav Kabrda - 0.6.0-4 +- Rebuilt for Ruby 1.9.3. + +* Sat Jan 14 2012 Fedora Release Engineering - 0.6.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Mon Jul 07 2011 Michal Fojtik - 0.6.0-2 +- Fixed broken RSpec tests by temporary removing bundler + +* Mon Jun 20 2011 Michal Fojtik - 0.6.0-1 +- Version bump + +* Wed Feb 09 2011 Fedora Release Engineering - 0.5.4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Wed Sep 08 2010 Michal Fojtik - 0.5.4-1 +- Update to 0.5.4 + +* Sun Jul 26 2009 Fedora Release Engineering - 0.4.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Tue Jun 30 2009 Lubomir Rintel (Good Data) - 0.4.0-1 +- Update to 0.4.0 +- Drop useless sitelib macro + +* Fri Jun 26 2009 Lubomir Rintel (Good Data) - 0.3.0-3 +- Get rid of duplicate files (thanks to Mamoru Tasaka) + +* Mon Jun 08 2009 Lubomir Rintel (Good Data) - 0.3.0-2 +- Fix up documentation list +- Depend on ruby(abi) +- Replace defines with globals + +* Fri Jun 05 2009 Lubomir Rintel (Good Data) - 0.3.0-1 +- Package generated by gem2rpm +- Fix up License