Skip to content

Loading…

Fix when using Rack > 1.3.6 #9

Closed
wants to merge 3 commits into from

6 participants

@chy-causer

This patch removes some lines which were causing problems with rack > 1.3.6. It also updates the test so that they work with Sinatra < 1.3.2 instead of < 1.0.

This is a direct fix for issue #8

@shiftb

+1 on this

@heptat

yeah, this works a treat, thanks

@tlianza

This would be great... it seems that without this, rack-flash does not work with modern versions of rack.

@chrismetcalf

Please!

@chy-causer

It looks like a gem has been pushed with the fix. Please see #8

@chy-causer chy-causer closed this
@tlianza tlianza referenced this pull request in sinatra/sinatra.github.com
Closed

Rack:Flash #56

@tsutsu tsutsu pushed a commit to peripia/rack-flash that referenced this pull request
@treeder treeder Applied fixes for new Rack's: nakajima/rack-flash#9 3c5fe88
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 14, 2012
  1. Remove builder stuff that seems useless

    Chris Causer committed
  2. Actually remove the dodgy stuff

    Chris Causer committed
  3. Update tests to work with 1.3.2 Sinatra

    Chris Causer committed
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 37 deletions.
  1. +0 −28 lib/rack/flash.rb
  2. +2 −7 test/helper.rb
  3. +8 −2 test/test_flash.rb
View
28 lib/rack/flash.rb
@@ -1,32 +1,4 @@
module Rack
- class Builder
- attr :ins
- def use(middleware, *args, &block)
- middleware.instance_variable_set "@rack_builder", self
- def middleware.rack_builder
- @rack_builder
- end
- @ins << lambda { |app|
- middleware.new(app, *args, &block)
- }
- end
-
- def run(app)
- klass = app.class
- klass.instance_variable_set "@rack_builder", self
- def klass.rack_builder
- @rack_builder
- end
- @ins << app #lambda { |nothing| app }
- end
-
- def leaf_app
- ins.last
- end
- end
-end
-
-module Rack
class Flash
# Raised when the session passed to FlashHash initialize is nil. This
# is usually an indicator that session middleware is not in use.
View
9 test/helper.rb
@@ -1,9 +1,8 @@
require 'rubygems'
-gem 'sinatra', '<1.0.0'
+gem 'sinatra', '<=1.3.2'
require 'sinatra/base'
require 'bacon'
-require 'sinatra/test'
-require 'sinatra/test/bacon'
+require 'rack/test'
require File.join(File.dirname(__FILE__), *%w[.. lib rack-flash])
class String
@@ -21,10 +20,6 @@ def err_explain
end
end
-def mock_app(&block)
- @app = Sinatra.new(&block)
-end
-
module Rack
class FakeFlash < Rack::Flash::FlashHash
attr_reader :flagged, :sweeped, :store
View
10 test/test_flash.rb
@@ -1,6 +1,12 @@
require File.dirname(__FILE__) + '/helper'
describe 'Rack::Flash' do
+ include Rack::Test::Methods
+
+ def app(&block)
+ return Sinatra.new &block
+ end
+
before do
@fake_session = {}
end
@@ -127,7 +133,7 @@ def new_flash(entries={})
describe 'integration' do
it 'provides :sweep option to clear unused entries' do
- mock_app {
+ app {
use Rack::Flash, :sweep => true
set :sessions, true
@@ -139,7 +145,7 @@ def new_flash(entries={})
fake_flash = Rack::FakeFlash.new(:foo => 'bar')
- get '/', :env => { 'x-rack.flash' => fake_flash }
+ get '/', :env=>{ 'x-rack.flash' => fake_flash }
fake_flash.should.be.flagged
fake_flash.should.be.swept
Something went wrong with that request. Please try again.