Permalink
Browse files

fixed event specs

  • Loading branch information...
1 parent 04d07f0 commit 6a0ffc6187796d31c5a0f4e0c7586c8d2bf2d9b7 @kristianmandrup committed Sep 16, 2012
@@ -4,12 +4,12 @@ def normalize event, *args
case event
when Controll::Event
event
- when Symbol
- create_event event, *args
+ when Symbol, String
+ create_event event.to_sym, *args
when Hash, Hashie::Mash
create_event event.delete(:name), event
else
- raise Controll::Event::InvalidError, "Event: #{event} could not be normalized, must be a Hash or Symbol"
+ raise Controll::Event::InvalidError, "Event: #{event} could not be normalized, must be a Hash, String or Symbol"
end
end
@@ -15,15 +15,15 @@ def render path
let(:controller) { MyController }
context 'instance' do
- describe 'do_redirect *args' do
+ describe 'do_redirect' do
specify do
- subject.do_redirect.should == nil
+ expect { subject.do_redirect }.to raise_error(ArgumentError)
end
end
- describe 'do_render *args' do
+ describe 'do_render' do
specify do
- subject.do_render.should == nil
+ expect { subject.do_render }.to raise_error(ArgumentError)
end
end
end
@@ -13,13 +13,21 @@ class Container
let(:event) { 'sign_in' }
let(:bad_event) { 'unknown' }
- describe '.initialize event' do
- its(:event) { should == 'sign_in' }
- end
+ describe '.normalize event' do
+ context 'Controll::Event' do
+ specify { subject.normalize(Controll::Event.new(:x)).should be_a Controll::Event }
+ end
+
+ context 'Symbol' do
+ specify { subject.normalize(:x).should be_a Controll::Event }
+ end
- describe '.match? events' do
- specify { subject.match?(events).should be_true }
+ context 'Hash' do
+ specify { subject.normalize(:name => :y).should be_a Controll::Event }
+ end
+ end
- specify { subject.match?(bad_events).should be_false }
+ describe '.create_event' do
+ specify { subject.create_event(:x).should be_a Controll::Event }
end
end
@@ -10,7 +10,8 @@
let(:bad_event) { 'unknown' }
describe '.initialize event' do
- its(:event) { should == 'sign_in' }
+ its(:event) { should be_a Controll::Event }
+ its('event.name') { should == :sign_in }
end
describe '.match? events' do

0 comments on commit 6a0ffc6

Please sign in to comment.