[PATCH] make Rack::Session::Cookie spec pass under 1.9.2dev

2 views
Skip to first unread message

Eric Wong

unread,
Dec 30, 2009, 8:37:05 PM12/30/09
to rack-...@googlegroups.com
There appears to be a small change to the Marshal output
under 1.9.2dev that makes it output differently than
under 1.9.1. Tested with Ruby trunk r26127.
---
Otoh, I feel this test is so fragile that it's probably best to
scrap it and rely on the round-trip tests...

Pushed out to the "mri-1.9.2dev" branch of git://git.bogomips.org/rack
http://git.bogomips.org/cgit/rack.git/commit/?h=mri-1.9.2dev

test/spec_rack_session_cookie.rb | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/test/spec_rack_session_cookie.rb b/test/spec_rack_session_cookie.rb
index 3be88b4..9b646f0 100644
--- a/test/spec_rack_session_cookie.rb
+++ b/test/spec_rack_session_cookie.rb
@@ -49,7 +49,10 @@ context "Rack::Session::Cookie" do

specify "creates a new cookie with integrity hash" do
res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor, :secret => 'test')).get("/")
- if RUBY_VERSION < "1.9"
+ case RUBY_VERSION
+ when "1.9.2"
+ res["Set-Cookie"].should.match("rack.session=BAh7BkkiDGNvdW50ZXIGOgZFRmkG%0A--2548b2a97e67656c3457b9a5cb43b65a83715cbc")
+ when "1.9.1"
res["Set-Cookie"].should.match("rack.session=BAh7BiIMY291bnRlcmkG%0A--1439b4d37b9d4b04c603848382f712d6fcd31088")
else
res["Set-Cookie"].should.match("rack.session=BAh7BkkiDGNvdW50ZXIGOg1lbmNvZGluZyINVVMtQVNDSUlpBg%3D%3D%0A--d7a6637b94d2728194a96c18484e1f7ed9074a83")
--
Eric Wong

Christian Neukirchen

unread,
Dec 31, 2009, 5:15:15 AM12/31/09
to rack-...@googlegroups.com
On Thu, Dec 31, 2009 at 2:37 AM, Eric Wong <normal...@yhbt.net> wrote:
>  Otoh, I feel this test is so fragile that it's probably best to
>  scrap it and rely on the round-trip tests...

+1

--
Christian Neukirchen <chneuk...@gmail.com> http://chneukirchen.org

Eric Wong

unread,
Dec 31, 2009, 3:19:29 PM12/31/09
to rack-...@googlegroups.com
Various versions/implementations of Ruby may Marshal data
differently. Instead of relying on a fragile test that
relies on exact byte sequence matches, just rely on existing
round-trip tests for the cookies.
---

Christian Neukirchen <chneuk...@gmail.com> wrote:
> On Thu, Dec 31, 2009 at 2:37 AM, Eric Wong <normal...@yhbt.net> wrote:
> > �Otoh, I feel this test is so fragile that it's probably best to
> > �scrap it and rely on the round-trip tests...
>
> +1

This patch squashes the previous one in this thread.

test/spec_rack_session_cookie.rb | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/test/spec_rack_session_cookie.rb b/test/spec_rack_session_cookie.rb
index 3be88b4..a164789 100644
--- a/test/spec_rack_session_cookie.rb
+++ b/test/spec_rack_session_cookie.rb
@@ -49,11 +49,7 @@ context "Rack::Session::Cookie" do



specify "creates a new cookie with integrity hash" do
res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor, :secret => 'test')).get("/")
- if RUBY_VERSION < "1.9"

- res["Set-Cookie"].should.match("rack.session=BAh7BiIMY291bnRlcmkG%0A--1439b4d37b9d4b04c603848382f712d6fcd31088")
- else
- res["Set-Cookie"].should.match("rack.session=BAh7BkkiDGNvdW50ZXIGOg1lbmNvZGluZyINVVMtQVNDSUlpBg%3D%3D%0A--d7a6637b94d2728194a96c18484e1f7ed9074a83")
- end
+ res["Set-Cookie"].should.match("rack.session=")
end

specify "loads from a cookie wih integrity hash" do
--
Eric Wong

Reply all
Reply to author
Forward
0 new messages