Skip to content

Commit

Permalink
Stripping some whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
bryckbost committed Sep 26, 2011
1 parent 8393cc1 commit e4611f9
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions spec/lifecycle_spec.rb
Expand Up @@ -11,26 +11,26 @@
before(:each) do
lifecycle.before(:execute, &callback)
end
it 'should execute before wrapped block' do

it 'should execute before wrapped block' do
callback.should_receive(:call).with(*arguments).ordered
behavior.should_receive(:inside!).ordered
lifecycle.run_callbacks :execute, *arguments, &wrapped_block
end
end

describe "after callbacks" do
before(:each) do
lifecycle.after(:execute, &callback)
end
it 'should execute after wrapped block' do

it 'should execute after wrapped block' do
behavior.should_receive(:inside!).ordered
callback.should_receive(:call).with(*arguments).ordered
lifecycle.run_callbacks :execute, *arguments, &wrapped_block
end
end

describe "around callbacks" do
before(:each) do
lifecycle.around(:execute) do |*args, &block|
Expand All @@ -39,69 +39,69 @@
behavior.after!
end
end
it 'should before and after wrapped block' do
behavior.should_receive(:before!).ordered

it 'should before and after wrapped block' do
behavior.should_receive(:before!).ordered
behavior.should_receive(:inside!).ordered
behavior.should_receive(:after!).ordered
behavior.should_receive(:after!).ordered
lifecycle.run_callbacks :execute, *arguments, &wrapped_block
end

it "should execute multiple callbacks in order" do
behavior.should_receive(:one).ordered
behavior.should_receive(:two).ordered
behavior.should_receive(:three).ordered

lifecycle.around(:execute) { |*args, &block| behavior.one; block.call(*args) }
lifecycle.around(:execute) { |*args, &block| behavior.two; block.call(*args) }
lifecycle.around(:execute) { |*args, &block| behavior.three; block.call(*args) }

lifecycle.run_callbacks(:execute, *arguments, &wrapped_block)
end
end

it "should raise if callback is executed with wrong number of parameters" do
lifecycle.before(:execute, &callback)
expect { lifecycle.run_callbacks(:execute, 1,2,3) {} }.to raise_error(ArgumentError, /1 parameter/)
end

# # This is a spectacularly crappy way to test callbacks. What's a better way?
# describe 'arguments callbacks' do
# describe 'arguments callbacks' do
# subject do
# class Testarguments < Delayed::arguments
# def before_execute; end
# def before_loop; end
# def before_perform; end
#
#
# set_callback :execute, :before, :before_execute
# set_callback :loop, :before, :before_loop
# set_callback :perform, :before, :before_perform
# end
#
#
# Testarguments.new.tap { |w| w.stop }
# end
#
#
# it "should trigger for execute event" do
# subject.should_receive(:before_execute).with()
# subject.start
# end
#
#
# it "should trigger for loop event" do
# subject.should_receive(:before_loop).with()
# subject.start
# end
#
#
# it "should trigger for perform event" do
# "foo".delay.length
# subject.should_receive(:before_perform).with()
# subject.start
# end
# end
#
# describe 'job callbacks' do
#
# describe 'job callbacks' do
# it "should trigger for enqueue event" do
# pending 'figure out how to test this'
# end
# end

end

0 comments on commit e4611f9

Please sign in to comment.