Browse files

fallback spec

  • Loading branch information...
1 parent 7818c43 commit 1a07a7a8b2d925e6b37cb34691d3c533d92133c7 @kristianmandrup committed Aug 18, 2012
View
14 lib/controll/flow_handler/fallback.rb
@@ -1,7 +1,19 @@
module Controll::FlowHandler
- class Fallback
+ class Fallback < Base
+ attr_reader :event
+
+ def initialize event
+ @event = event
+ end
+
def perform controller
controller.fallback
end
+
+ class << self
+ def action event
+ self.new event
+ end
+ end
end
end
View
2 lib/controll/flow_handler/redirecter.rb
@@ -1,7 +1,7 @@
require 'controll/flow_handler/base'
module Controll::FlowHandler
- class Redirecter < Base
+ class Redirecter < Base
autoload :Action, 'controll/flow_handler/redirect/action'
autoload :Mapper, 'controll/flow_handler/redirect/mapper'
View
27 spec/controll/flow_handler/fallback_spec.rb
@@ -0,0 +1,27 @@
+require 'spec_helper'
+
+class BasicFallback < Controll::FlowHandler::Fallback
+ def perform
+ 'hello'
+ end
+end
+
+describe Controll::FlowHandler::Fallback do
+ context 'override perform' do
+ subject { clazz.new '/' }
+
+ let(:clazz) { BasicFallback }
+
+ describe '.action event' do
+ specify do
+ clazz.action(:hello).should be_a Controll::FlowHandler::Fallback
+ end
+ end
+
+ describe '.perform' do
+ specify do
+ clazz.action(:hello).perform.should == 'hello'
+ end
+ end
+ end
+end
View
54 spec/controll/flow_handler/redirect_spec.rb
@@ -32,41 +32,41 @@ def error name
}
end
- # context 'use directly without subclassing' do
- # subject { clazz.new '/' }
+ context 'use directly without subclassing' do
+ subject { clazz.new '/' }
- # let(:clazz) { Controll::FlowHandler::Redirect }
+ let(:clazz) { Controll::FlowHandler::Redirect }
- # let(:hello) { notification :hello }
+ let(:hello) { notification :hello }
- # describe '.action event' do
- # specify do
- # expect { clazz.action(:hello) }.to raise_error(Controll::FlowHandler::Redirect::NoRedirectionFoundError)
- # end
- # end
- # end
+ describe '.action event' do
+ specify do
+ expect { clazz.action(:hello) }.to raise_error(Controll::FlowHandler::Redirect::NoRedirectionFoundError)
+ end
+ end
+ end
- # context 'HelloToWelcomeRedirect subclass' do
- # subject { clazz.new '/' }
+ context 'HelloToWelcomeRedirect subclass' do
+ subject { clazz.new '/' }
- # let(:clazz) { HelloToWelcomeRedirect }
+ let(:clazz) { HelloToWelcomeRedirect }
- # context 'has redirections' do
- # describe '.action event' do
- # specify do
- # expect { clazz.action(:hello) }.to_not raise_error(Controll::FlowHandler::Redirect::NoRedirectionFoundError)
- # end
+ context 'has redirections' do
+ describe '.action event' do
+ specify do
+ expect { clazz.action(:hello) }.to_not raise_error(Controll::FlowHandler::Redirect::NoRedirectionFoundError)
+ end
- # specify do
- # clazz.action(:hello).should be_a HelloToWelcomeRedirect
- # end
+ specify do
+ clazz.action(:hello).should be_a HelloToWelcomeRedirect
+ end
- # specify do
- # clazz.action(:hi).path.should == 'welcome'
- # end
- # end
- # end
- # end
+ specify do
+ clazz.action(:hi).path.should == 'welcome'
+ end
+ end
+ end
+ end
context 'ErrorBadRedirect subclass' do
subject { clazz.new '/' }

0 comments on commit 1a07a7a

Please sign in to comment.