spec/controller/actions_spec.rb in happy-0.1.0.pre16 vs spec/controller/actions_spec.rb in happy-0.1.0.pre19
- old
+ new
@@ -38,10 +38,23 @@
end
it "finishes the rendering by throwing :done" do
expect { subject.serve! "body" }.to throw_symbol :done
end
+
+ 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
+ serve! "But this should render"
+ end
+ end
+ end
+
+ response_for { get '/test' }.body.should == "But this should render"
+ end
end
describe '#redirect!' do
it "triggers a redirection to the specified URL" do
def app
@@ -58,9 +71,25 @@
build_controller { redirect! 'http://www.test.com', 301 }
end
get '/'
last_response.status.should == 301
+ end
+
+ 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
+ redirect! "http://schnitzelpress.org"
+ end
+ end
+ end
+
+ get '/test'
+ last_response.should be_redirect
+ last_response.headers['Location'].should == 'http://schnitzelpress.org'
end
end
describe '#run' do
it "passes control to another controller" do