test/sinatra/test_multi_actions.rb in jellyfish-1.0.0 vs test/sinatra/test_multi_actions.rb in jellyfish-1.0.1
- old
+ new
@@ -1,21 +1,21 @@
require 'jellyfish/test'
# stolen from sinatra
describe 'Sinatra filter_test.rb' do
- behaves_like :jellyfish
+ paste :jellyfish
def new_app base=Object, &block
Class.new(base){
include Jellyfish
controller_include(Jellyfish::MultiActions)
instance_eval(&block)
}.new
end
- should 'executes filters in the order defined' do
+ would 'executes filters in the order defined' do
count = 0
app = new_app{
get { count.should.eq 0; count = 1 }
get { count.should.eq 1; count = 2 }
get('/'){ 'Hello World' }
@@ -25,33 +25,33 @@
status.should.eq 200
count .should.eq 2
body .should.eq ['Hello World']
end
- should 'modify env' do
+ would 'modify env' do
app = new_app{
get{ env['BOO'] = 'MOO' }
get('/foo'){ env['BOO'] }
}
status, _, body = get('/foo', app)
status.should.eq 200
body .should.eq ['MOO']
end
- should 'modify instance variables available to routes' do
+ would 'modify instance variables available to routes' do
app = new_app{
get{ @foo = 'bar' }
get('/foo') { @foo }
}
status, _, body = get('/foo', app)
status.should.eq 200
body .should.eq ['bar']
end
- should 'allows redirects' do
+ would 'allows redirects' do
app = new_app{
get{ found '/bar' }
get('/foo') do
fail 'before block should have halted processing'
'ORLY?!'
@@ -62,11 +62,11 @@
status .should.eq 302
headers['Location'].should.eq '/bar'
body.join .should =~ %r{<h1>Jellyfish found: /bar</h1>}
end
- should 'not modify the response with its return value' do
+ would 'not modify the response with its return value' do
app = new_app{
get{ 'Hello World!' }
get '/foo' do
body.should.eq nil
'cool'
@@ -76,11 +76,11 @@
status, _, body = get('/foo', app)
status.should.eq 200
body .should.eq ['cool']
end
- should 'modify the response with halt' do
+ would 'modify the response with halt' do
app = new_app{
get('/foo'){ halt [302, {}, ['Hi']] }
get('/foo'){ 'should not happen' }
get('/bar'){ status 402; body 'Ho'; halt }
get('/bar'){ 'should not happen' }
@@ -88,33 +88,33 @@
get('/foo', app).should.eq [302, {}, ['Hi']]
get('/bar', app).should.eq [402, {}, ['Ho']]
end
- should 'give you access to params' do
+ would 'give you access to params' do
app = new_app{
get{ @foo = Rack::Request.new(env).params['foo'] }
get('/foo'){ @foo.reverse }
}
status, _, body = get('/foo', app, 'QUERY_STRING' => 'foo=cool')
status.should.eq 200
body .should.eq ['looc']
end
- should 'run filters defined in superclasses' do
+ would 'run filters defined in superclasses' do
sup = new_app{ get{ @foo = 'hello from superclass' } }.class
app = new_app(sup){ get('/foo'){ @foo } }
_, _, body = get('/foo', app)
body.should.eq ['hello from superclass']
sup .routes['get'].size.should.eq 1
app.class.routes['get'].size.should.eq 2
end
- should 'take an optional route pattern' do
+ would 'take an optional route pattern' do
ran_filter = false
app = new_app{
get(%r{^/b}){ ran_filter = true }
get('/foo') {}
get('/bar') {}
@@ -123,20 +123,20 @@
ran_filter.should.eq false
get('/bar', app)
ran_filter.should.eq true
end
- should 'generate block arguments from route pattern' do
+ would 'generate block arguments from route pattern' do
subpath = nil
app = new_app{
get(%r{^/foo/(\w+)}){ |m| subpath = m[1] }
}
get('/foo/bar', app)
subpath.should.eq 'bar'
end
- should 'execute before and after filters in correct order' do
+ would 'execute before and after filters in correct order' do
invoked = 0
app = new_app{
get { invoked = 2 }
get('/'){ invoked += 2; body 'hello' }
get { invoked *= 2 }
@@ -146,11 +146,11 @@
status .should.eq 200
body .should.eq ['hello']
invoked.should.eq 8
end
- should 'execute filters in the order defined' do
+ would 'execute filters in the order defined' do
count = 0
app = new_app{
get('/'){ body 'Hello World' }
get{
count.should.eq 0
@@ -166,11 +166,11 @@
status.should.eq 200
count .should.eq 2
body .should.eq ['Hello World']
end
- should 'allow redirects' do
+ would 'allow redirects' do
app = new_app{
get('/foo'){ 'ORLY' }
get { found '/bar' }
}
@@ -178,32 +178,32 @@
status .should.eq 302
headers['Location'].should.eq '/bar'
body.join .should =~ %r{<h1>Jellyfish found: /bar</h1>}
end
- should 'not modify the response with its return value' do
+ would 'not modify the response with its return value' do
app = new_app{
get('/foo'){ body 'cool' }
get { 'Hello World!' }
}
status, _, body = get('/foo', app)
status.should.eq 200
body .should.eq ['cool']
end
- should 'modify the response with halt' do
+ would 'modify the response with halt' do
app = new_app{
get('/foo'){ 'should not be returned' }
get{ halt [302, {}, ['Hi']] }
}
status, _, body = get('/foo', app)
status.should.eq 302
body .should.eq ['Hi']
end
- should 'take an optional route pattern' do
+ would 'take an optional route pattern' do
ran_filter = false
app = new_app{
get('/foo') {}
get('/bar') {}
get(%r{^/b}){ ran_filter = true }