Skip to content

Commit

Permalink
reordered / contextulized prolog tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crux committed Aug 19, 2013
1 parent efb7689 commit 50b2cfa
Showing 1 changed file with 42 additions and 40 deletions.
82 changes: 42 additions & 40 deletions spec/applix_spec.rb
Expand Up @@ -90,28 +90,50 @@
end
end #.cluster

it 'prolog can even temper with arguments to modify the handle sequence' do
Applix.main(['a', 'b']) do
prolog { |args, options|
args.should == ['a', 'b']
args.reverse!
}
handle(:a) { raise 'should not be called!' }
handle(:b) { :b_was_called }
end.should == :b_was_called
end
context 'prolog invokations' do
it 'prolog can even temper with arguments to modify the handle sequence' do
Applix.main(['a', 'b']) do
prolog { |args, options|
args.should == ['a', 'b']
args.reverse!
}
handle(:a) { raise 'should not be called!' }
handle(:b) { :b_was_called }
end.should == :b_was_called
end

it 'prolog has read/write access to args and options' do
Applix.main(['func']) do
prolog { |args, options|
args.should == ['func']
options[:prolog] = Time.now
}
it 'prolog has read/write access to args and options' do
Applix.main(['func']) do
prolog { |args, options|
args.should == ['func']
options[:prolog] = Time.now
}

handle(:func) { |*_, options|
options[:prolog]
}
end.should_not == nil
end

handle(:func) { |*_, options|
options[:prolog]
}
end.should_not == nil
it 'runs before callback before handle calls' do
Applix.main(['func']) do

# @prolog will be available in handle invocations
prolog {
@prolog = :prolog
}

# @epilog will NOT make it into the handle invocation
epilog { |rc, *_|
@epilog = :epilog
rc
}

handle(:func) {
[@prolog, @epilog]
}
end.should == [:prolog, nil]
end
end

it 'epilog has access to task handler results' do
Expand All @@ -126,26 +148,6 @@
end.should == [3, 2, 1]
end

it 'runs before callback before handle calls' do
Applix.main(['func']) do

# @prolog will be available in handle invocations
prolog {
@prolog = :prolog
}

# @epilog will NOT make it into the handle invocation
epilog { |rc, *_|
@epilog = :epilog
rc
}

handle(:func) {
[@prolog, @epilog]
}
end.should == [:prolog, nil]
end

it 'runs epilog callback after handle' do
last_action = nil
Applix.main([:func]) do
Expand Down

0 comments on commit 50b2cfa

Please sign in to comment.