spec/controller/actions_spec.rb in happy-0.1.0.pre22 vs spec/controller/actions_spec.rb in happy-0.1.0.pre23
- old
+ new
@@ -4,15 +4,15 @@
describe Controller::Actions do
subject { Controller.new }
describe '#serve!' do
def app
- build_controller do
- path?('simple') { serve! "Simple response" }
- path?('with_headers') { serve! "body { color: red }", :content_type => 'text/css' }
- path?('with_status') { serve! "Not Allowed", :status => 401 }
- path?('with_layout') { serve! "content", :layout => 'layout.erb' }
+ Happy.route do
+ on('simple') { serve! "Simple response" }
+ on('with_headers') { serve! "body { color: red }", :content_type => 'text/css' }
+ on('with_status') { serve! "Not Allowed", :status => 401 }
+ on('with_layout') { serve! "content", :layout => 'layout.erb' }
end
end
it "serves the provided string as the response body" do
response_for { get '/simple' }.body.should == 'Simple response'
@@ -43,11 +43,11 @@
it "doesn't do anything if the current path does not match the request path" do
def app
Happy.route do
serve! "This should not render"
- path? 'test' do
+ on 'test' do
serve! "But this should render"
end
end
end
@@ -56,21 +56,21 @@
end
describe '#redirect!' do
it "triggers a redirection to the specified URL" do
def app
- build_controller { redirect! 'http://www.test.com' }
+ Happy.route { redirect! 'http://www.test.com' }
end
get '/'
last_response.status.should == 302
last_response.headers['Location'].should == 'http://www.test.com'
end
it "sets the provided status code" do
def app
- build_controller { redirect! 'http://www.test.com', 301 }
+ Happy.route { redirect! 'http://www.test.com', 301 }
end
get '/'
last_response.status.should == 301
end
@@ -78,11 +78,11 @@
it "doesn't do anything if the current path does not match the request path" do
def app
Happy.route do
redirect! "http://mans.de"
- path? 'test' do
+ on 'test' do
redirect! "http://schnitzelpress.org"
end
end
end
@@ -99,11 +99,11 @@
'awesome!'
end
end
def app
- build_controller { run InnerController }
+ Happy.route { run InnerController }
end
response_for { get '/' }.body.should == 'awesome!'
end
@@ -113,11 +113,11 @@
Rack::Response.new('racksome!')
end
end
def app
- build_controller { run SomeRackApp }
+ Happy.route { run SomeRackApp }
end
response_for { get '/' }.body.should == 'racksome!'
end
@@ -127,10 +127,10 @@
"stringsome!"
end
end
def app
- build_controller { run SomeClass }
+ Happy.route { run SomeClass }
end
response_for { get '/' }.body.should == 'stringsome!'
end
end