Modified: incubator/buildr/trunk/spec/artifact_spec.rb URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/artifact_spec.rb?rev=608657&r1=608656&r2=608657&view=diff ============================================================================== --- incubator/buildr/trunk/spec/artifact_spec.rb (original) +++ incubator/buildr/trunk/spec/artifact_spec.rb Thu Jan 3 14:15:24 2008 @@ -279,23 +279,6 @@ end -describe "repositories.proxy" do - before do - repositories.remote = "http://example.com" - end - - it "should be empty initially" do - repositories.proxy.should be_nil - end - - it "should be used when downloading" do - repositories.proxy = "http://myproxy:8080" - Net::HTTP.should_receive(:start).with(anything, 80, "myproxy", 8080, nil, nil).twice - artifact("com.example:library:jar:all:2.0").invoke - end -end - - describe "repositories.release_to" do it "should accept URL as first argument" do repositories.release_to = "http://example.com" @@ -466,7 +449,7 @@ before do @spec = 'group:id:jar:1.0' write @file = 'test.jar' - repositories.deploy_to = 'sftp://example.com/base' + repositories.release_to = 'sftp://example.com/base' end it 'should return the upload task' do @@ -486,25 +469,6 @@ URI.should_receive(:upload).once. with(URI.parse('sftp://example.com/base/group/id/1.0/id-1.0.pom'), artifact(@spec).pom.to_s, anything) upload.invoke - end -end - - -describe Buildr, "#deploy" do - before do - repositories.deploy_to = "sftp://example.com/base" - @file = file("README") - write @file.to_s - end - - it "should deploy a file to a path using its basename" do - URI.should_receive(:upload).once.with(URI.parse("sftp://example.com/base/README"), @file.to_s, anything) - deploy @file - end - - it "should deploy a file to specified path and basename" do - URI.should_receive(:upload).once.with(URI.parse("sftp://example.com/base/foo/bar/README"), @file.to_s, anything) - deploy @file, :path=>"foo/bar" end end
Modified: incubator/buildr/trunk/spec/build_spec.rb URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/build_spec.rb?rev=608657&r1=608656&r2=608657&view=diff ============================================================================== --- incubator/buildr/trunk/spec/build_spec.rb (original) +++ incubator/buildr/trunk/spec/build_spec.rb Thu Jan 3 14:15:24 2008 @@ -1,22 +1,81 @@ require File.join(File.dirname(__FILE__), 'sandbox') - -describe 'Local directory build task' do - it 'should execute build task for current project' do +describe 'local task', :shared=>true do + it "should execute task for project in current directory" do define 'foobar' - lambda { task('build').invoke }.should run_task('foobar:build') + lambda { @task.invoke }.should run_task("foobar:[EMAIL PROTECTED]") end - it 'should not execute build task for other projects' do + it "should not execute task for projects in other directory" do define 'foobar', :base_dir=>'elsewhere' lambda { task('build').invoke }.should_not run_task('foobar:build') end end -describe Project, ' build task' do +describe 'build task' do + it_should_behave_like 'local task' + before(:each) { @task = task('build') } +end + +describe 'clean task' do + it_should_behave_like 'local task' + before(:each) { @task = task('clean') } +end + +describe 'package task' do + it_should_behave_like 'local task' + before(:each) { @task = task('package') } + + it 'should execute build task as prerequisite' do + lambda { @task.invoke }.should run_task('build') + end +end + +describe 'install task' do + it_should_behave_like 'local task' + before(:each) { @task = task('install') } + + it 'should execute package task as prerequisite' do + lambda { @task.invoke }.should run_task('package') + end +end + +describe 'uninstall task' do + it_should_behave_like 'local task' + before(:each) { @task = task('uninstall') } +end + +describe 'upload task' do + it_should_behave_like 'local task' + before(:each) { @task = task('upload') } + + it 'should execute package task as prerequisite' do + lambda { @task.invoke }.should run_task('package') + end +end + + +describe Project, '#build' do + it 'should return the project\'s build task' do + define('foo').build.should eql(task('foo:build')) + end + + it 'should enhance the project\'s build task' do + task 'prereq' + task 'action' + define 'foo' do + build 'prereq' do + task('action').invoke + end + end + lambda { project('foo').build.invoke }.should run_tasks('prereq', 'action') + end + it 'should execute build task for sub-project' do - define('foo') { define 'bar' } + define 'foo' do + define 'bar' + end lambda { task('foo:build').invoke }.should run_task('foo:bar:build') end @@ -25,15 +84,57 @@ define 'bar' lambda { task('foo:build').invoke }.should_not run_task('bar:build') end +end - it 'should be accessible as build method' do - define 'boo' - project('boo').build.should be(task('boo:build')) + +describe Project, '#clean' do + it 'should return the project\'s clean task' do + define('foo').clean.should eql(task('foo:clean')) + end + + it 'should enhance the project\'s clean task' do + task 'prereq' + task 'action' + define 'foo' do + clean 'prereq' do + task('action').invoke + end + end + lambda { project('foo').clean.invoke }.should run_tasks('prereq', 'action') + end + + it 'should remove target directory' do + define 'foo' do + self.layout[:target] = 'targeted' + end + mkpath 'targeted' + lambda { project('foo').clean.invoke }.should change { File.exist?('targeted') }.from(true).to(false) + end + + it 'should remove reports directory' do + define 'foo' do + self.layout[:reports] = 'reported' + end + mkpath 'reported' + lambda { project('foo').clean.invoke }.should change { File.exist?('reported') }.from(true).to(false) + end + + it 'should execute clean task for sub-project' do + define 'foo' do + define 'bar' + end + lambda { task('foo:clean').invoke }.should run_task('foo:bar:clean') + end + + it 'should not execute clean task of other projects' do + define 'foo' + define 'bar' + lambda { task('foo:clean').invoke }.should_not run_task('bar:clean') end end -describe Project, 'target' do +describe Project, '#target' do before :each do @project = define('foo', :layout=>Layout.new) end @@ -54,7 +155,7 @@ end -describe Project, 'reports' do +describe Project, '#reports' do before :each do @project = define('foo', :layout=>Layout.new) end Modified: incubator/buildr/trunk/spec/packaging_spec.rb URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/packaging_spec.rb?rev=608657&r1=608656&r2=608657&view=diff ============================================================================== --- incubator/buildr/trunk/spec/packaging_spec.rb (original) +++ incubator/buildr/trunk/spec/packaging_spec.rb Thu Jan 3 14:15:24 2008 @@ -742,15 +742,6 @@ define_method(:packaging) { :zip } it_should_behave_like "packaging" - it "should accept files from :include option" do - write "test" - define("foo", :version=>"1.0") { package(:zip, :include=>"test") } - project("foo").package(:zip).invoke - Zip::ZipFile.open(project("foo").package(:zip).to_s) do |zip| - zip.entries.map(&:to_s).should include("test") - end - end - it "should not include META-INF directory" do define("foo", :version=>"1.0") { package(:zip) } project("foo").package(:zip).invoke @@ -768,22 +759,6 @@ define_method(:meta_inf) { "MANIFEST.MF" } it_should_behave_like "package_with_meta_inf" - it "should accept files from :include option" do - write "test" - write "src/main/java/Test.java", "class Test {}" - define("foo", :version=>"1.0") { package(:jar, :include=>"test") } - project("foo").package(:jar).invoke - Zip::ZipFile.open(project("foo").package(:jar).to_s) do |jar| - jar.entries.map(&:to_s).sort.should include("META-INF/MANIFEST.MF", "test") - end - end - - it "should warn that :include option is deprecated" do - define "foo", :version=>"1.0" do - verbose(true) { lambda { package(:jar, :include=>"test") }.should warn_that(/:include option .* is deprecated/) } - end - end - it "should use files from compile directory if nothing included" do write "src/main/java/Test.java", "class Test {}" define("foo", :version=>"1.0") { package(:jar) } @@ -850,19 +825,6 @@ end end - it "should accept files from :include option" do - write "test" - write "src/main/webapp/test.html" - define("foo", :version=>"1.0") { package(:war, :include=>"test") } - inspect_war { |files| files.should include("META-INF/MANIFEST.MF", "test") } - end - - it "should warn that :include option is deprecated" do - define "foo", :version=>"1.0" do - verbose(true) { lambda { package(:war, :include=>"test") }.should warn_that(/:include option .* is deprecated/) } - end - end - it "should use files from webapp directory if nothing included" do write "src/main/webapp/test.html" define("foo", :version=>"1.0") { package(:war) } @@ -877,16 +839,10 @@ it "should accept files from :classes option" do write "src/main/java/Test.java", "class Test {}" write "classes/test" - define("foo", :version=>"1.0") { package(:war, :classes=>"classes") } + define("foo", :version=>"1.0") { package(:war).with(:classes=>"classes") } inspect_war { |files| files.should include("WEB-INF/classes/test") } end - it "should warn that :classes option is deprecated" do - define "foo", :version=>"1.0" do - verbose(true) { lambda { package(:war, :classes=>"classes") }.should warn_that(/:classes option .* is deprecated/) } - end - end - it "should use files from compile directory if nothing included" do write "src/main/java/Test.java", "class Test {}" define("foo", :version=>"1.0") { package(:war) } @@ -919,19 +875,13 @@ it "should accept file from :libs option" do make_jars - define("foo", :version=>"1.0") { package(:war, :libs=>"group:id:jar:1.0") } + define("foo", :version=>"1.0") { package(:war).with(:libs=>"group:id:jar:1.0") } inspect_war { |files| files.should include("META-INF/MANIFEST.MF", "WEB-INF/lib/id-1.0.jar") } end - it "should warn that :libs option is deprecated" do - define "foo", :version=>"1.0" do - verbose(true) { lambda { package(:war, :libs=>"group:id:jar:1.0") }.should warn_that(/:libs option .* is deprecated/) } - end - end - it "should accept file from :libs option" do make_jars - define("foo", :version=>"1.0") { package(:war, :libs=>["group:id:jar:1.0", "group:id:jar:2.0"]) } + define("foo", :version=>"1.0") { package(:war).with(:libs=>["group:id:jar:1.0", "group:id:jar:2.0"]) } inspect_war { |files| files.should include("META-INF/MANIFEST.MF", "WEB-INF/lib/id-1.0.jar", "WEB-INF/lib/id-2.0.jar") } end Modified: incubator/buildr/trunk/spec/project_spec.rb URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/project_spec.rb?rev=608657&r1=608656&r2=608657&view=diff ============================================================================== --- incubator/buildr/trunk/spec/project_spec.rb (original) +++ incubator/buildr/trunk/spec/project_spec.rb Thu Jan 3 14:15:24 2008 @@ -732,7 +732,7 @@ end -describe Rake::Task, ' buildr:initialize' do +describe Rake::Task, 'buildr:initialize' do it 'should be ready to run as the first task' do Rake.application.top_level_tasks.first.should eql('buildr:initialize') end @@ -743,5 +743,3 @@ lambda { task('buildr:initialize').invoke }.should change { defined }.to(true) end end - - Modified: incubator/buildr/trunk/spec/sandbox.rb URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/sandbox.rb?rev=608657&r1=608656&r2=608657&view=diff ============================================================================== --- incubator/buildr/trunk/spec/sandbox.rb (original) +++ incubator/buildr/trunk/spec/sandbox.rb Thu Jan 3 14:15:24 2008 @@ -11,7 +11,7 @@ # that the code requires several artifacts. So we establish them first using the real local # repository and cache these across test cases. repositories.remote << "http://repo1.maven.org/maven2" - Java.wrapper.load # Anything added to the classpath. + Java.load # Anything added to the classpath. artifacts(TestFramework.frameworks.values.map(&:requires).flatten).each { |a| file(a).invoke } task("buildr:initialize").invoke Modified: incubator/buildr/trunk/spec/test_spec.rb URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/test_spec.rb?rev=608657&r1=608656&r2=608657&view=diff ============================================================================== --- incubator/buildr/trunk/spec/test_spec.rb (original) +++ incubator/buildr/trunk/spec/test_spec.rb Thu Jan 3 14:15:24 2008 @@ -239,7 +239,7 @@ end -describe Buildr::TestFramework::JUnit do +describe Buildr::JUnit do before do write "src/test/java/PassingTest.java", "public class PassingTest extends junit.framework.TestCase { public void testNothing() {} }" @@ -249,15 +249,15 @@ end it "should include JUnit requirements" do - project("foo").test.requires.should include(*TestFramework::JUnit::JUNIT_REQUIRES) - project("foo").test.compile.dependencies.should include(*artifacts(TestFramework::JUnit::JUNIT_REQUIRES)) - project("foo").test.dependencies.should include(*artifacts(TestFramework::JUnit::JUNIT_REQUIRES)) + project("foo").test.requires.should include(*JUnit::REQUIRES) + project("foo").test.compile.dependencies.should include(*artifacts(JUnit::REQUIRES)) + project("foo").test.dependencies.should include(*artifacts(JUnit::REQUIRES)) end it "should include JMock requirements" do - project("foo").test.requires.should include(*TestFramework::JMock::JMOCK_REQUIRES) - project("foo").test.compile.dependencies.should include(*artifacts(TestFramework::JMock::JMOCK_REQUIRES)) - project("foo").test.dependencies.should include(*artifacts(TestFramework::JMock::JMOCK_REQUIRES)) + project("foo").test.requires.should include(*JMock::REQUIRES) + project("foo").test.compile.dependencies.should include(*artifacts(JMock::REQUIRES)) + project("foo").test.dependencies.should include(*artifacts(JMock::REQUIRES)) end it "should include classes starting with and ending with Test" do @@ -339,15 +339,15 @@ end it "should include TestNG requirements" do - project("foo").test.requires.should include(*TestFramework::TestNG::TESTNG_REQUIRES) - project("foo").test.compile.dependencies.should include(*artifacts(TestFramework::TestNG::TESTNG_REQUIRES)) - project("foo").test.dependencies.should include(*artifacts(TestFramework::TestNG::TESTNG_REQUIRES)) + project("foo").test.requires.should include(*TestNG::REQUIRES) + project("foo").test.compile.dependencies.should include(*artifacts(TestNG::REQUIRES)) + project("foo").test.dependencies.should include(*artifacts(TestNG::REQUIRES)) end it "should include TestNG requirements" do - project("foo").test.requires.should include(*TestFramework::JMock::JMOCK_REQUIRES) - project("foo").test.compile.dependencies.should include(*artifacts(TestFramework::JMock::JMOCK_REQUIRES)) - project("foo").test.dependencies.should include(*artifacts(TestFramework::JMock::JMOCK_REQUIRES)) + project("foo").test.requires.should include(*JMock::REQUIRES) + project("foo").test.compile.dependencies.should include(*artifacts(JMock::REQUIRES)) + project("foo").test.dependencies.should include(*artifacts(JMock::REQUIRES)) end it "should include classes starting with and ending with Test" do @@ -693,17 +693,17 @@ describe Rake::Task, "junit:report" do it "should default to the target directory reports/junit" do - TestFramework::JUnit.report.target.should eql("reports/junit") + JUnit.report.target.should eql("reports/junit") end it "should generate report into the target directory" do - TestFramework::JUnit.report.target = "test-report" - lambda { task("junit:report").invoke }.should change { File.exist?(TestFramework::JUnit.report.target) }.to(true) + JUnit.report.target = "test-report" + lambda { task("junit:report").invoke }.should change { File.exist?(JUnit.report.target) }.to(true) end it "should clean after itself" do - mkpath TestFramework::JUnit.report.target - lambda { task("clean").invoke }.should change { File.exist?(TestFramework::JUnit.report.target) }.to(false) + mkpath JUnit.report.target + lambda { task("clean").invoke }.should change { File.exist?(JUnit.report.target) }.to(false) end it "should generate a consolidated XML report" do @@ -711,17 +711,17 @@ end it "should default to generating a report with frames" do - TestFramework::JUnit.report.frames.should be_true + JUnit.report.frames.should be_true end it "should generate single page when frames is false" do - TestFramework::JUnit.report.frames = false + JUnit.report.frames = false task("junit:report").invoke file("reports/junit/html/junit-noframes.html").should exist end it "should generate frame page when frames is false" do - TestFramework::JUnit.report.frames = true + JUnit.report.frames = true task("junit:report").invoke file("reports/junit/html/index.html").should exist end @@ -736,7 +736,7 @@ end after do - TestFramework::JUnit.instance_eval { @report = nil } + JUnit.instance_eval { @report = nil } end end
