1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
require 'sinatra/base'
require 'bacon'
require 'rack/test'
require 'rack-flash'
class String
[:green, :yellow, :red].each { |c| define_method(c) { self } }
end if ENV['TM_RUBY']
# bacon swallows errors alive
def err_explain
begin
yield
rescue => e
puts e.inspect
puts e.backtrace
raise e
end
end
module Rack
class FakeFlash < Rack::Flash::FlashHash
attr_reader :flagged, :sweeped, :store
def initialize(*args)
@flagged, @sweeped = false, false
@store = {}
super(@store)
end
def flag!
@flagged = true
super
end
def sweep!
@sweeped = true
super
end
def flagged?
@flagged
end
def swept?
@sweeped
end
end
end
|