1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
require File.expand_path('../../ant_spec_helper', __FILE__)
describe Ant, "targets" do
include Ant::RSpec::AntExampleGroup
it "should delay executing tasks in targets until the target is executed" do
ant = example_ant :name => "foo" do
target :foo do
property :name => "foo", :value => "bar"
end
end
ant.properties["foo"].should_not == "bar"
ant.execute_target(:foo)
ant.properties["foo"].should == "bar"
end
it "#ant should accumulate targets and tasks in the same global project" do
ant do
target :a
end
ant do
target :b
end
ant.project.targets.keys.to_a.should include("a", "b")
end
it "should heed :if and :unless conditions" do
message = ""
ant = example_ant do
property :name => "foo", :value => "defined"
target :will_never_execute, :if => "not.defined" do
message << "will_never_execute?"
end
target :also_will_never_execute, :unless => "foo" do
message << "also_will_never_execute"
end
target :may_execute, :if => "bar" do
message << "executed"
end
end
ant.execute_target(:will_never_execute)
ant.execute_target(:also_will_never_execute)
ant.execute_target(:may_execute)
message.should == ""
ant.property :name => "bar", :value => "defined"
ant.execute_target(:may_execute)
message.should_not == ""
end
it "should execute target tasks and non-tasks in order" do
ant = example_ant do
target :foo do
property :name => "bar", :value => "true"
ant.properties["bar"].should == "true"
end
end
ant.execute_target(:foo)
end
it "should be executable if it doesn't have a block" do
ant = example_ant do
target :foo do
property :name => "bar", :value => "true"
ant.properties["bar"].should == "true"
end
target :bar, :depends => :foo
end
ant.execute_target(:bar)
end
it "does not support antcall for calling other targets" do
ant = example_ant do
target :foo
target :bar do
antcall :target => :foo
end
end
lambda { ant.execute_target(:bar) }.should raise_error
end
it "does not support ant for calling other buildfiles" do
a = example_ant do
target :foo
target :bar do
ant :antfile => "some-file", :target => :foo
end
end
lambda { a.execute_target(:bar) }.should raise_error
end
end
|