Skip to content
Browse files

Applied fixes for new Rack's: #9

  • Loading branch information...
1 parent 480600d commit 3c5fe88d8f7e2ad2e54f62ead17b667522a6c9c9 @treeder treeder committed Mar 19, 2012
Showing with 12 additions and 38 deletions.
  1. +0 −27 lib/rack/flash.rb
  2. +3 −8 test/helper.rb
  3. +9 −3 test/test_flash.rb
View
27 lib/rack/flash.rb
@@ -1,32 +1,5 @@
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
11 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
@@ -53,4 +48,4 @@ def swept?
@sweeped
end
end
-end
+end
View
12 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
@@ -148,4 +154,4 @@ def new_flash(entries={})
end
# Testing sessions is a royal pain in the ass.
-end
+end

0 comments on commit 3c5fe88

Please sign in to comment.
Something went wrong with that request. Please try again.