Created
August 4, 2009 17:32
-
-
Save nakajima/161369 to your computer and use it in GitHub Desktop.
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
[~/Desktop/gist-161426][master] spec rack-flash\ spec.rb | |
.... | |
Finished in 0.021006 seconds | |
4 examples, 0 failures |
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
require 'sinatra' | |
require 'rack-flash' | |
use Rack::Flash | |
get '/' do | |
flash[:message] || 'No flash' | |
end | |
get '/set' do | |
flash[:message] = 'Hello!' | |
'Flash message set!' | |
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
require 'rubygems' | |
require 'spec' | |
require 'spec/interop/test' | |
require 'rack-flash example.rb' | |
require 'rack/test' | |
require 'rack/flash/test' | |
Sinatra::Base.set :environment, :test | |
Spec::Runner.configure { |c| c.include Rack::Test::Methods } | |
def app | |
Sinatra::Application.new | |
end | |
describe 'Test' do | |
specify 'no flash' do | |
get '/' | |
last_response.body.should == 'No flash' | |
end | |
specify 'flash' do | |
get '/set' | |
get '/' | |
last_response.body.should == 'Hello!' | |
get '/' | |
last_response.body.should == 'No flash' | |
end | |
specify 'we are in test mode' do | |
assert_equal :test, Sinatra::Base.environment | |
end | |
specify 'flash in test environment' do | |
get '/set' | |
get '/' | |
last_response.body.should == 'Hello!' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment