Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started adding tests, cleared up documentation.
- Loading branch information
Showing
4 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'rubygems' | ||
require 'sinatra/base' | ||
require 'bacon' | ||
require 'sinatra/test' | ||
require 'sinatra/test/bacon' | ||
require File.join(File.dirname(__FILE__), *%w[.. lib sinatra-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 | ||
|
||
def mock_app(&block) | ||
@app = Sinatra.new(&block) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require File.dirname(__FILE__) + '/helper' | ||
|
||
describe 'Sinatra::Flash' do | ||
before do | ||
mock_app { | ||
include Sinatra::Flash | ||
|
||
set :sessions, false | ||
|
||
get '/view' do | ||
flash[:notice] | ||
end | ||
|
||
post '/set' do | ||
flash[:notice] = params[:q] | ||
redirect '/view' | ||
end | ||
} | ||
end | ||
|
||
it 'is empty by default' do | ||
err_explain do | ||
get '/view' | ||
body.should.be.empty | ||
end | ||
end | ||
|
||
# Testing sessions is a royal pain in the ass. | ||
end |