Skip to content
This repository

Fix when using Rack > 1.3.6 #9

Closed
wants to merge 3 commits into from

6 participants

Christopher Causer Brandon Leonardo heptat Tom Lianza Neil Pullman Chris Metcalf
Christopher 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

Brandon Leonardo

+1 on this

heptat

yeah, this works a treat, thanks

Tom Lianza

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

Chris Metcalf

Please!

Christopher Causer chy-causer closed this March 29, 2012
Christopher Causer

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

Tom Lianza tlianza referenced this pull request in sinatra/sinatra.github.com October 19, 2012
Closed

Rack:Flash #56

Levi Aul tsutsu referenced this pull request from a commit in peripia/rack-flash March 19, 2012
Travis Reeder 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

Showing 3 unique commits by 1 author.

Feb 14, 2012
Remove builder stuff that seems useless 43d462e
Actually remove the dodgy stuff 44b5c40
Update tests to work with 1.3.2 Sinatra d8fd1d2
This page is out of date. Refresh to see the latest.
28  lib/rack/flash.rb
... ...
@@ -1,32 +1,4 @@
1 1
 module Rack
2  
-  class Builder
3  
-    attr :ins
4  
-    def use(middleware, *args, &block)
5  
-      middleware.instance_variable_set "@rack_builder", self
6  
-      def middleware.rack_builder
7  
-        @rack_builder
8  
-      end
9  
-      @ins << lambda { |app|
10  
-        middleware.new(app, *args, &block)
11  
-      }
12  
-    end
13  
-
14  
-    def run(app)
15  
-      klass = app.class
16  
-      klass.instance_variable_set "@rack_builder", self
17  
-      def klass.rack_builder
18  
-        @rack_builder
19  
-      end
20  
-      @ins << app #lambda { |nothing| app }
21  
-    end
22  
-
23  
-    def leaf_app
24  
-      ins.last
25  
-    end
26  
-  end
27  
-end
28  
-
29  
-module Rack
30 2
   class Flash
31 3
     # Raised when the session passed to FlashHash initialize is nil. This
32 4
     # is usually an indicator that session middleware is not in use.
9  test/helper.rb
... ...
@@ -1,9 +1,8 @@
1 1
 require 'rubygems'
2  
-gem 'sinatra', '<1.0.0'
  2
+gem 'sinatra', '<=1.3.2'
3 3
 require 'sinatra/base'
4 4
 require 'bacon'
5  
-require 'sinatra/test'
6  
-require 'sinatra/test/bacon'
  5
+require 'rack/test'
7 6
 require File.join(File.dirname(__FILE__), *%w[.. lib rack-flash])
8 7
 
9 8
 class String
@@ -21,10 +20,6 @@ def err_explain
21 20
   end
22 21
 end
23 22
 
24  
-def mock_app(&block)
25  
-  @app = Sinatra.new(&block)
26  
-end
27  
-
28 23
 module Rack
29 24
   class FakeFlash < Rack::Flash::FlashHash
30 25
     attr_reader :flagged, :sweeped, :store
10  test/test_flash.rb
... ...
@@ -1,6 +1,12 @@
1 1
 require File.dirname(__FILE__) + '/helper'
2 2
 
3 3
 describe 'Rack::Flash' do
  4
+  include Rack::Test::Methods
  5
+
  6
+  def app(&block)
  7
+    return Sinatra.new &block
  8
+  end
  9
+
4 10
   before do
5 11
     @fake_session = {}
6 12
   end
@@ -127,7 +133,7 @@ def new_flash(entries={})
127 133
 
128 134
   describe 'integration' do
129 135
     it 'provides :sweep option to clear unused entries' do
130  
-      mock_app {
  136
+      app {
131 137
         use Rack::Flash, :sweep => true
132 138
 
133 139
         set :sessions, true
@@ -139,7 +145,7 @@ def new_flash(entries={})
139 145
 
140 146
       fake_flash = Rack::FakeFlash.new(:foo => 'bar')
141 147
 
142  
-      get '/', :env => { 'x-rack.flash' => fake_flash }
  148
+      get '/', :env=>{ 'x-rack.flash' => fake_flash }
143 149
 
144 150
       fake_flash.should.be.flagged
145 151
       fake_flash.should.be.swept
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.