You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by as...@apache.org on 2008/01/16 10:11:43 UTC

svn commit: r612391 [2/2] - in /incubator/buildr/trunk: ./ doc/ doc/css/ doc/pages/ lib/ lib/buildr/ lib/buildr/jetty/ lib/core/ lib/java/ lib/java/org/apache/buildr/ lib/tasks/ spec/

Modified: incubator/buildr/trunk/spec/common_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/common_spec.rb?rev=612391&r1=612390&r2=612391&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/common_spec.rb (original)
+++ incubator/buildr/trunk/spec/common_spec.rb Wed Jan 16 01:11:40 2008
@@ -1,79 +1,78 @@
 require File.join(File.dirname(__FILE__), 'spec_helpers')
 
-
 describe Buildr.method(:struct) do
   before do
-    @hash = { :foo=>"foo:jar", :bar=>"bar:jar" }
+    @hash = { :foo=>'foo:jar', :bar=>'bar:jar' }
     @struct = struct(@hash)
   end
 
-  it "should be object with key-value pairs" do
-    @struct.foo.should eql("foo:jar")
-    @struct.bar.should eql("bar:jar")
+  it 'should be object with key-value pairs' do
+    @struct.foo.should eql('foo:jar')
+    @struct.bar.should eql('bar:jar')
   end
 
-  it "should fail when requesting non-existent key" do
+  it 'should fail when requesting non-existent key' do
     lambda { @struct.foobar }.should raise_error(NoMethodError)
   end
 
-  it "should return members when requested" do
+  it 'should return members when requested' do
     @struct.members.sort.should eql(@hash.keys.map(&:to_s).sort)
   end
 
-  it "should return valued when requested" do
+  it 'should return valued when requested' do
     @struct.values.sort.should eql(@hash.values.sort)
   end
 end
 
 
 describe Buildr.method(:write) do
-  it "should create path" do
-    write "foo/test"
-    File.directory?("foo").should be_true
-    File.exist?("foo/test").should be_true
+  it 'should create path' do
+    write 'foo/test'
+    File.directory?('foo').should be_true
+    File.exist?('foo/test').should be_true
   end
 
-  it "should write content to file" do
-    write "test", "content"
-    File.read("test").should eql("content")
+  it 'should write content to file' do
+    write 'test', 'content'
+    File.read('test').should eql('content')
   end
 
-  it "should retrieve content from block, if block given" do
-    write("test") { "block" }
-    File.read("test").should eql("block")
+  it 'should retrieve content from block, if block given' do
+    write('test') { 'block' }
+    File.read('test').should eql('block')
   end
 
-  it "should write empty file if no content provided" do
-    write "test"
-    File.read("test").should eql("")
+  it 'should write empty file if no content provided' do
+    write 'test'
+    File.read('test').should eql('')
   end
 
-  it "should return content as a string" do
-    write("test", "content").should eql("content")
+  it 'should return content as a string' do
+    write('test', 'content').should eql('content')
   end
 
-  it "should return empty string if no content provided" do
-    write("test").should eql("")
+  it 'should return empty string if no content provided' do
+    write('test').should eql('')
   end
 end
 
 
 describe Buildr.method(:read) do
   before do
-    write @file = "test", @content = "content"
+    write @file = 'test', @content = 'content'
   end
 
-  it "should return contents of named file" do
+  it 'should return contents of named file' do
     read(@file).should eql(@content)
   end
 
-  it "should yield to block if block given" do
+  it 'should yield to block if block given' do
     read @file do |content|
       content.should eql(@content)
     end
   end
 
-  it "should return block response if block given" do
+  it 'should return block response if block given' do
     read(@file) { 5 }.should be(5)
   end
 end
@@ -81,60 +80,60 @@
 
 describe Buildr.method(:download) do
   before do
-    @content = "we has download!"
+    @content = 'we has download!'
     @http = mock('http')
     @http.stub!(:request).and_return(Net::HTTPNotModified.new(nil, nil, nil))
   end
 
   def tasks()
-    [ download("http://localhost/download"), download("downloaded"=>"http://localhost/download") ]
+    [ download('http://localhost/download'), download('downloaded'=>'http://localhost/download') ]
   end
 
-  it "should be a file task" do
+  it 'should be a file task' do
     tasks.each { |task| task.should be_kind_of(Rake::FileTask) }
   end
 
-  it "should accept a String and download from that URL" do
-    download("http://localhost/download").tap do |task|
+  it 'should accept a String and download from that URL' do
+    download('http://localhost/download').tap do |task|
       task.source.should_receive(:read).and_yield [@content]
       task.invoke
       task.should contain(@content)
     end
   end
 
-  it "should accept a URI and download from that URL" do
-    download(URI.parse("http://localhost/download")).tap do |task|
+  it 'should accept a URI and download from that URL' do
+    download(URI.parse('http://localhost/download')).tap do |task|
       task.source.should_receive(:read).and_yield [@content]
       task.invoke
       task.should contain(@content)
     end
   end
 
-  it "should accept a path and String and download from that URL" do
-    download("downloaded"=>"http://localhost/download").tap do |task|
+  it 'should accept a path and String and download from that URL' do
+    download('downloaded'=>'http://localhost/download').tap do |task|
       task.source.should_receive(:read).and_yield [@content]
       task.invoke
       task.should contain(@content)
     end
   end
 
-  it "should accept a path and URI and download from that URL" do
-    download("downloaded"=>URI.parse("http://localhost/download")).tap do |task|
+  it 'should accept a path and URI and download from that URL' do
+    download('downloaded'=>URI.parse('http://localhost/download')).tap do |task|
       task.source.should_receive(:read).and_yield [@content]
       task.invoke
       task.should contain(@content)
     end
   end
 
-  it "should create path for download" do
-    download("path/downloaded"=>URI.parse("http://localhost/download")).tap do |task|
+  it 'should create path for download' do
+    download('path/downloaded'=>URI.parse('http://localhost/download')).tap do |task|
       task.source.should_receive(:read).and_yield [@content]
       task.invoke
       task.should contain(@content)
     end
   end
 
-  it "should fail if resource not found" do
+  it 'should fail if resource not found' do
     tasks.each do |task|
       task.source.should_receive(:read).and_raise URI::NotFoundError
       lambda { task.invoke }.should raise_error(URI::NotFoundError)
@@ -142,7 +141,7 @@
     tasks.last.should_not exist
   end
 
-  it "should fail on any other error" do
+  it 'should fail on any other error' do
     tasks.each do |task|
       task.source.should_receive(:read).and_raise RuntimeError
       lambda { task.invoke }.should raise_error(RuntimeError)
@@ -150,28 +149,28 @@
     tasks.last.should_not exist
   end
 
-  it "should execute only if file does not already exist" do
-    download("downloaded"=>"http://localhost/download").tap do |task|
+  it 'should execute only if file does not already exist' do
+    download('downloaded'=>'http://localhost/download').tap do |task|
       task.source.should_not_receive(:read)
-      write task.to_s, "not really"
+      write task.to_s, 'not really'
       task.invoke
     end
   end
 
-  it "should execute without a proxy if none specified" do
-    Net::HTTP.should_receive(:new).with("localhost", 80).twice.and_return(@http)
+  it 'should execute without a proxy if none specified' do
+    Net::HTTP.should_receive(:new).with('localhost', 80).twice.and_return(@http)
     tasks.each(&:invoke)
   end
 
-  it "should pass Buildr proxy options" do
-    Buildr.options.proxy.http = "http://proxy:8080"
-    Net::HTTP.should_receive(:new).with("localhost", 80, "proxy", 8080, nil, nil).twice.and_return(@http)
+  it 'should pass Buildr proxy options' do
+    Buildr.options.proxy.http = 'http://proxy:8080'
+    Net::HTTP.should_receive(:new).with('localhost', 80, 'proxy', 8080, nil, nil).twice.and_return(@http)
     tasks.each(&:invoke)
   end
 
-  it "should set HTTP proxy from HTTP_PROXY environment variable" do
-    ENV["HTTP_PROXY"] = "http://proxy:8080"
-    Net::HTTP.should_receive(:new).with("localhost", 80, "proxy", 8080, nil, nil).twice.and_return(@http)
+  it 'should set HTTP proxy from HTTP_PROXY environment variable' do
+    ENV['HTTP_PROXY'] = 'http://proxy:8080'
+    Net::HTTP.should_receive(:new).with('localhost', 80, 'proxy', 8080, nil, nil).twice.and_return(@http)
     tasks.each(&:invoke)
   end
 end
@@ -179,23 +178,23 @@
 
 describe Buildr.method(:filter) do
   def source
-    File.expand_path("src")
+    File.expand_path('src')
   end
   
-  it "should return a Filter for the source" do
+  it 'should return a Filter for the source' do
     filter(source).should be_kind_of(Filter)
   end
 
-  it "should use the source directory" do
+  it 'should use the source directory' do
     filter(source).sources.should include(file(source))
   end
 
-  it "should use the source directories" do
-    dirs = ["first", "second"]
-    filter("first", "second").sources.should include(*dirs.map { |dir| file(dir) })
+  it 'should use the source directories' do
+    dirs = ['first', 'second']
+    filter('first', 'second').sources.should include(*dirs.map { |dir| file(dir) })
   end
 
-  it "should accept a file task" do
+  it 'should accept a file task' do
     task = file(source)
     filter(task).sources.each { |source| source.should be(task) }
   end
@@ -209,209 +208,209 @@
     @early = Time.now - 1000
   end
 
-  it "should respond to :from and return self" do
-    @filter.from("src").should be(@filter)
+  it 'should respond to :from and return self' do
+    @filter.from('src').should be(@filter)
   end
 
-  it "should respond to :from and add source directory" do
-    lambda { @filter.from("src") }.should change { @filter.sources }
+  it 'should respond to :from and add source directory' do
+    lambda { @filter.from('src') }.should change { @filter.sources }
   end
 
-  it "should respond to :from and add source directories" do
-    dirs = ["first", "second"]
+  it 'should respond to :from and add source directories' do
+    dirs = ['first', 'second']
     @filter.from(*dirs)
     @filter.sources.should include(*dirs.map { |dir| file(dir) })
   end
 
-  it "should return source directories as file task" do
-    @filter.from("src").sources.each { |source| source.should be_kind_of(Rake::FileTask) }
+  it 'should return source directories as file task' do
+    @filter.from('src').sources.each { |source| source.should be_kind_of(Rake::FileTask) }
   end
 
-  it "should return source directories as expanded path" do
-    @filter.from("src").sources.each { |source| source.to_s.should eql("src") }
+  it 'should return source directories as expanded path' do
+    @filter.from('src').sources.each { |source| source.to_s.should eql('src') }
   end
 
-  it "should respond to :into and return self" do
-    @filter.into("target").should be(@filter)
+  it 'should respond to :into and return self' do
+    @filter.into('target').should be(@filter)
   end
 
-  it "should respond to :into and set target directory" do
-    lambda { @filter.into("src") }.should change { @filter.target }
-    @filter.into("target").target.should be(file('target'))
+  it 'should respond to :into and set target directory' do
+    lambda { @filter.into('src') }.should change { @filter.target }
+    @filter.into('target').target.should be(file('target'))
   end
 
-  it "should return target directory as file task" do
-    @filter.into("target").target.should be_kind_of(Rake::FileTask)
+  it 'should return target directory as file task' do
+    @filter.into('target').target.should be_kind_of(Rake::FileTask)
   end
 
-  it "should return target directory as expanded path" do
-    @filter.into("target").target.to_s.should eql('target')
+  it 'should return target directory as expanded path' do
+    @filter.into('target').target.to_s.should eql('target')
   end
 
-  it "should respond to :using and return self" do
+  it 'should respond to :using and return self' do
     @filter.using().should be(@filter)
   end
 
-  it "should respond to :using and set mapping from the argument" do
-    mapping = { "foo"=>"bar" }
+  it 'should respond to :using and set mapping from the argument' do
+    mapping = { 'foo'=>'bar' }
     lambda { @filter.using mapping }.should change { @filter.mapping }.to(mapping)
   end
 
-  it "should respond to :using and set mapping from the block" do
+  it 'should respond to :using and set mapping from the block' do
     @filter.using { 5 }.mapping.call.should be(5)
   end
 
-  it "should respond to :include and return self" do
-    @filter.include("file").should be(@filter)
+  it 'should respond to :include and return self' do
+    @filter.include('file').should be(@filter)
   end
 
-  it "should respond to :include and use these inclusion patterns" do
-    @filter.from("src").into("target").include("file2", "file3").run
-    Dir["target/*"].should eql(["target/file2", "target/file3"])
+  it 'should respond to :include and use these inclusion patterns' do
+    @filter.from('src').into('target').include('file2', 'file3').run
+    Dir['target/*'].should eql(['target/file2', 'target/file3'])
   end
 
-  it "should respond to :exclude and return self" do
-    @filter.exclude("file").should be(@filter)
+  it 'should respond to :exclude and return self' do
+    @filter.exclude('file').should be(@filter)
   end
 
-  it "should respond to :exclude and use these exclusion patterns" do
-    @filter.from("src").into("target").exclude("file2", "file3").run
-    Dir["target/*"].sort.should eql(["target/file1", "target/file4"])
+  it 'should respond to :exclude and use these exclusion patterns' do
+    @filter.from('src').into('target').exclude('file2', 'file3').run
+    Dir['target/*'].sort.should eql(['target/file1', 'target/file4'])
   end
 
-  it "should copy files over" do
-    @filter.from("src").into("target").run
-    Dir["target/*"].sort.each do |file|
+  it 'should copy files over' do
+    @filter.from('src').into('target').run
+    Dir['target/*'].sort.each do |file|
       read(file).should eql("#{File.basename(file)} raw")
     end
   end
 
-  it "should copy dot files over" do
-    write "src/.config", "# configuration"
-    @filter.from("src").into("target").run
-    read("target/.config").should eql("# configuration")
+  it 'should copy dot files over' do
+    write 'src/.config', '# configuration'
+    @filter.from('src').into('target').run
+    read('target/.config').should eql('# configuration')
   end
 
-  it "should copy empty directories as well" do
-    mkpath "src/empty"
-    @filter.from("src").into("target").run
-    File.directory?("target/empty").should be_true
+  it 'should copy empty directories as well' do
+    mkpath 'src/empty'
+    @filter.from('src').into('target').run
+    File.directory?('target/empty').should be_true
   end
 
-  it "should copy files from multiple source directories" do
+  it 'should copy files from multiple source directories' do
     4.upto(6) { |i| write "src2/file#{i}", "file#{i} raw" }
-    @filter.from("src", "src2").into("target").run
-    Dir["target/*"].each do |file|
+    @filter.from('src', 'src2').into('target').run
+    Dir['target/*'].each do |file|
       read(file).should eql("#{File.basename(file)} raw")
     end
-    Dir["target/*"].should include(*(1..6).map { |i| "target/file#{i}" })
+    Dir['target/*'].should include(*(1..6).map { |i| "target/file#{i}" })
   end
 
-  it "should copy files recursively" do
-    mkpath "src/path1" ; write "src/path1/left"
-    mkpath "src/path2" ; write "src/path2/right"
-    @filter.from("src").into("target").run
-    Dir["target/**/*"].should include(*(1..4).map { |i| "target/file#{i}" })
-    Dir["target/**/*"].should include("target/path1/left", "target/path2/right")
+  it 'should copy files recursively' do
+    mkpath 'src/path1' ; write 'src/path1/left'
+    mkpath 'src/path2' ; write 'src/path2/right'
+    @filter.from('src').into('target').run
+    Dir['target/**/*'].should include(*(1..4).map { |i| "target/file#{i}" })
+    Dir['target/**/*'].should include('target/path1/left', 'target/path2/right')
   end
 
-  it "should apply hash mapping using Maven style" do
+  it 'should apply hash mapping using Maven style' do
     1.upto(4) { |i| write "src/file#{i}", "file#{i} with ${key1} and ${key2}" }
-    @filter.from("src").into("target").using("key1"=>"value1", "key2"=>"value2").run
-    Dir["target/*"].each do |file|
+    @filter.from('src').into('target').using('key1'=>'value1', 'key2'=>'value2').run
+    Dir['target/*'].each do |file|
       read(file).should eql("#{File.basename(file)} with value1 and value2")
     end
   end
 
-  it "should apply hash mapping using Ant style" do
+  it 'should apply hash mapping using Ant style' do
     1.upto(4) { |i| write "src/file#{i}", "file#{i} with @key1@ and @key2@" }
-    @filter.from("src").into("target").using(:ant, "key1"=>"value1", "key2"=>"value2").run
-    Dir["target/*"].each do |file|
+    @filter.from('src').into('target').using(:ant, 'key1'=>'value1', 'key2'=>'value2').run
+    Dir['target/*'].each do |file|
       read(file).should eql("#{File.basename(file)} with value1 and value2")
     end
   end
 
-  it "should apply hash mapping using Ruby style" do
+  it 'should apply hash mapping using Ruby style' do
     1.upto(4) { |i| write "src/file#{i}", "file#{i} with \#{key1} and \#{key2}" }
-    @filter.from("src").into("target").using(:ruby, "key1"=>"value1", "key2"=>"value2").run
-    Dir["target/*"].each do |file|
+    @filter.from('src').into('target').using(:ruby, 'key1'=>'value1', 'key2'=>'value2').run
+    Dir['target/*'].each do |file|
       read(file).should eql("#{File.basename(file)} with value1 and value2")
     end
   end
 
-  it "should using Maven mapper by default" do
-    @filter.using("key1"=>"value1", "key2"=>"value2").mapper.should eql(:maven)
+  it 'should using Maven mapper by default' do
+    @filter.using('key1'=>'value1', 'key2'=>'value2').mapper.should eql(:maven)
   end
 
-  it "should apply hash mapping using regular expression" do
+  it 'should apply hash mapping using regular expression' do
     1.upto(4) { |i| write "src/file#{i}", "file#{i} with #key1# and #key2#" }
-    @filter.from("src").into("target").using(/#(.*?)#/, "key1"=>"value1", "key2"=>"value2").run
-    Dir["target/*"].each do |file|
+    @filter.from('src').into('target').using(/#(.*?)#/, 'key1'=>'value1', 'key2'=>'value2').run
+    Dir['target/*'].each do |file|
       read(file).should eql("#{File.basename(file)} with value1 and value2")
     end
   end
 
-  it "should apply proc mapping" do
-    @filter.from("src").into("target").using { |file, content| "proc mapped" }.run
-    Dir["target/*"].each do |file|
-      read(file).should eql("proc mapped")
+  it 'should apply proc mapping' do
+    @filter.from('src').into('target').using { |file, content| 'proc mapped' }.run
+    Dir['target/*'].each do |file|
+      read(file).should eql('proc mapped')
     end
   end
 
-  it "should apply proc mapping with relative file name" do
-    @filter.from("src").into("target").using { |file, content| file.should =~ /^file\d$/ }.run
+  it 'should apply proc mapping with relative file name' do
+    @filter.from('src').into('target').using { |file, content| file.should =~ /^file\d$/ }.run
   end
 
-  it "should apply proc mapping with file content" do
-    @filter.from("src").into("target").using { |file, content| content.should =~ /^file\d raw/ }.run
+  it 'should apply proc mapping with file content' do
+    @filter.from('src').into('target').using { |file, content| content.should =~ /^file\d raw/ }.run
   end
 
-  it "should make target directory" do
-    lambda { @filter.from("src").into("target").run }.should change { File.exist?("target") }.to(true)
+  it 'should make target directory' do
+    lambda { @filter.from('src').into('target').run }.should change { File.exist?('target') }.to(true)
   end
 
-  it "should touch target directory" do
-    mkpath "target" ; File.utime @early, @early, "target"
-    @filter.from("src").into("target").run
-    File.mtime("target").should be_close(Time.now, 10)
+  it 'should touch target directory' do
+    mkpath 'target' ; File.utime @early, @early, 'target'
+    @filter.from('src').into('target').run
+    File.mtime('target').should be_close(Time.now, 10)
   end
 
-  it "should not touch target directory unless running" do
-    mkpath "target" ; File.utime @early, @early, "target"
-    @filter.from("src").into("target").exclude("*").run
-    File.mtime("target").should be_close(@early, 10)
+  it 'should not touch target directory unless running' do
+    mkpath 'target' ; File.utime @early, @early, 'target'
+    @filter.from('src').into('target').exclude('*').run
+    File.mtime('target').should be_close(@early, 10)
   end
 
-  it "should run only one new files" do
-    @filter.from("src").into("target").run
-    @filter.from("src").into("target").using { |file, content| file.should eql("file2") }.run
+  it 'should run only one new files' do
+    @filter.from('src').into('target').run
+    @filter.from('src').into('target').using { |file, content| file.should eql('file2') }.run
   end
 
-  it "should return true when run copies any files" do
-    @filter.from("src").into("target").run.should be(true)
+  it 'should return true when run copies any files' do
+    @filter.from('src').into('target').run.should be(true)
   end
 
-  it "should return false when run does not copy any files" do
-    @filter.from("src").into("target").run
-    @filter.from("src").into("target").run.should be(false)
+  it 'should return false when run does not copy any files' do
+    @filter.from('src').into('target').run
+    @filter.from('src').into('target').run.should be(false)
   end
 
-  it "should fail is source directory not set" do
-    lambda { Filter.new.into("target").run }.should raise_error(RuntimeError, /No source directory/)
+  it 'should fail is source directory not set' do
+    lambda { Filter.new.into('target').run }.should raise_error(RuntimeError, /No source directory/)
   end
 
-  it "should fail if source directory doesn't exist" do
-    lambda { Filter.new.from("srced").into("target").run }.should raise_error(RuntimeError, /doesn't exist/)
+  it 'should fail if source directory doesn\'t exist' do
+    lambda { Filter.new.from('srced').into('target').run }.should raise_error(RuntimeError, /doesn't exist/)
   end
 
-  it "should fail is target directory not set" do
-    lambda { Filter.new.from("src").run }.should raise_error(RuntimeError, /No target directory/)
+  it 'should fail is target directory not set' do
+    lambda { Filter.new.from('src').run }.should raise_error(RuntimeError, /No target directory/)
   end
 
-  it "should copy read-only files as writeable" do
-    Dir["src/*"].each { |file| File.chmod(0444, file) }
-    @filter.from("src").into("target").run
-    Dir["target/*"].sort.each do |file|
+  it 'should copy read-only files as writeable' do
+    Dir['src/*'].each { |file| File.chmod(0444, file) }
+    @filter.from('src').into('target').run
+    Dir['target/*'].sort.each do |file|
       File.readable?(file).should be_true
       File.writable?(file).should be_true
       (File.stat(file).mode & 0x0fff).should be(0664)
@@ -421,78 +420,78 @@
 
 
 describe Buildr.method(:options) do
-  it "should return an Options object" do
+  it 'should return an Options object' do
     options.should be_kind_of(Options)
   end
 
-  it "should return an Options object each time" do
+  it 'should return an Options object each time' do
     options.should be(options)
   end
 
-  it "should return the same Options object when called on Object, Buildr or Project" do
+  it 'should return the same Options object when called on Object, Buildr or Project' do
     options.should be(Buildr.options)
-    define("foo") { options.should be(Buildr.options) }
+    define('foo') { options.should be(Buildr.options) }
   end
 end
 
 
-describe Buildr::Options, " proxy.exclude" do
+describe Buildr::Options, ' proxy.exclude' do
   before do
-    options.proxy.http = "http://myproxy:8080"
-    @domain = "domain"
+    options.proxy.http = 'http://myproxy:8080'
+    @domain = 'domain'
     @host = "host.#{@domain}"
     @uri = URI("http://#{@host}")
     @no_proxy_args = [@host, 80]
-    @proxy_args = @no_proxy_args + ["myproxy", 8080, nil, nil]
+    @proxy_args = @no_proxy_args + ['myproxy', 8080, nil, nil]
     @http = mock('http')
     @http.stub!(:request).and_return(Net::HTTPNotModified.new(nil, nil, nil))
   end
 
-  it "should be an array" do
+  it 'should be an array' do
     options.proxy.exclude.should be_empty
     options.proxy.exclude = @domain
     options.proxy.exclude.should include(@domain)
   end
 
-  it "should support adding to array" do
+  it 'should support adding to array' do
     options.proxy.exclude << @domain
     options.proxy.exclude.should include(@domain)
   end
 
-  it "should support resetting array" do
+  it 'should support resetting array' do
     options.proxy.exclude = @domain
     options.proxy.exclude = nil
     options.proxy.exclude.should be_empty
   end
 
-  it "should use proxy when not excluded" do
+  it 'should use proxy when not excluded' do
     Net::HTTP.should_receive(:new).with(*@proxy_args).and_return(@http)
     @uri.read :proxy=>options.proxy
   end
 
-  it "should use proxy unless excluded" do
+  it 'should use proxy unless excluded' do
     options.proxy.exclude = "not.#{@domain}"
     Net::HTTP.should_receive(:new).with(*@proxy_args).and_return(@http)
     @uri.read :proxy=>options.proxy
   end
 
-  it "should not use proxy if excluded" do
+  it 'should not use proxy if excluded' do
     options.proxy.exclude = @host
     Net::HTTP.should_receive(:new).with(*@no_proxy_args).and_return(@http)
     @uri.read :proxy=>options.proxy
   end
 
-  it "should support multiple host names" do
-    options.proxy.exclude = ["optimus", "prime"]
-    Net::HTTP.should_receive(:new).with("optimus", 80).and_return(@http)
-    URI("http://optimus").read :proxy=>options.proxy
-    Net::HTTP.should_receive(:new).with("prime", 80).and_return(@http)
-    URI("http://prime").read :proxy=>options.proxy
-    Net::HTTP.should_receive(:new).with("bumblebee", *@proxy_args[1..-1]).and_return(@http)
-    URI("http://bumblebee").read :proxy=>options.proxy
+  it 'should support multiple host names' do
+    options.proxy.exclude = ['optimus', 'prime']
+    Net::HTTP.should_receive(:new).with('optimus', 80).and_return(@http)
+    URI('http://optimus').read :proxy=>options.proxy
+    Net::HTTP.should_receive(:new).with('prime', 80).and_return(@http)
+    URI('http://prime').read :proxy=>options.proxy
+    Net::HTTP.should_receive(:new).with('bumblebee', *@proxy_args[1..-1]).and_return(@http)
+    URI('http://bumblebee').read :proxy=>options.proxy
   end
 
-  it "should support glob pattern on host name" do
+  it 'should support glob pattern on host name' do
     options.proxy.exclude = "*.#{@domain}"
     Net::HTTP.should_receive(:new).with(*@no_proxy_args).and_return(@http)
     @uri.read :proxy=>options.proxy
@@ -500,39 +499,63 @@
 end
 
 
-describe Hash, "::from_java_properties" do
-  it "should return hash" do
-    hash = Hash.from_java_properties("name1=value1\nname2=value2")
-    hash.should == {"name1"=>"value1", "name2"=>"value2"}
+describe Hash, '::from_java_properties' do
+  it 'should return hash' do
+    hash = Hash.from_java_properties(<<-PROPS)
+name1=value1
+name2=value2
+    PROPS
+    hash.should == {'name1'=>'value1', 'name2'=>'value2'}
   end
 
-  it "should ignore comments and empty lines" do
-    hash = Hash.from_java_properties("\n\nname1=value1\n\n\nname2=value2\n\n")
-    hash.should == {"name1"=>"value1", "name2"=>"value2"}
+  it 'should ignore comments and empty lines' do
+    hash = Hash.from_java_properties(<<-PROPS)
+
+name1=value1
+
+name2=value2
+
+PROPS
+    hash.should == {'name1'=>'value1', 'name2'=>'value2'}
   end
 
-  it "should allow multiple lines" do
-    hash = Hash.from_java_properties("\nname1=start\\\n end\n\nname2=first\\\n second \\\nthird\n\n")
-    hash.should == {"name1"=>"start end", "name2"=>"first second third"}
+  it 'should allow multiple lines' do
+    hash = Hash.from_java_properties(<<-PROPS)
+name1=start\
+ end
+
+name2=first\
+ second\
+ third
+
+PROPS
+    hash.should == {'name1'=>'start end', 'name2'=>'first second third'}
   end
 
-  it "should handle \\t, \\r, \\n and \\f" do
-    hash = Hash.from_java_properties("\n\nname1=with\\tand\\r\n\n\nname2=with\\nand\\f\n\nname3=double\\\\hash")
-    hash.should == {"name1"=>"with\tand\r", "name2"=>"with\nand\f", "name3"=>"double\\hash"}
+  it 'should handle \t, \r, \n and \f' do
+    hash = Hash.from_java_properties(<<-PROPS)
+
+name1=with\tand\r
+
+name2=with\\nand\f
+
+name3=double\\hash
+PROPS
+    hash.should == {'name1'=>"with\tand\r", 'name2'=>"with\nand\f", 'name3'=>"double\\hash"}
   end
 end
 
 
-describe Hash, "#to_java_properties" do
-  it "should return name/value pairs" do
-    props = {"name1"=>"value1", "name2"=>"value2"}.to_java_properties
+describe Hash, '#to_java_properties' do
+  it 'should return name/value pairs' do
+    props = {'name1'=>'value1', 'name2'=>'value2'}.to_java_properties
     props.split("\n").size.should be(2)
-    props.split("\n").should include("name1=value1")
-    props.split("\n").should include("name2=value2")
+    props.split("\n").should include('name1=value1')
+    props.split("\n").should include('name2=value2')
   end
 
-  it "should handle \\t, \\r, \\n and \\f" do
-    props = {"name1"=>"with\tand\r", "name2"=>"with\nand\f", "name3"=>"double\\hash"}.to_java_properties
+  it 'should handle \t, \r, \n and \f' do
+    props = {'name1'=>"with\tand\r", 'name2'=>"with\nand\f", 'name3'=>"double\\hash"}.to_java_properties
     props.split("\n").should include("name1=with\\tand\\r")
     props.split("\n").should include("name2=with\\nand\\f")
     props.split("\n").should include("name3=double\\\\hash")
@@ -540,13 +563,40 @@
 end
 
 
+describe Buildr, 'environment' do
+  it 'should default to development' do
+    environment.should eql('development')
+  end
+  
+  it 'should come from BUILDR_ENV environment variable' do
+    ENV['BUILDR_ENV'] = 'buildr-test'
+    environment.should eql('buildr-test')
+  end
+
+  it 'should change the environment variable' do
+    Buildr.environment = 'buildr-test'
+    ENV['BUILDR_ENV'].should eql('buildr-test')
+  end
+end
+
+
 describe Buildr, 'profiles' do
   it 'should return empty hash if no profiles file' do
     Buildr.profiles.should == {}
   end
 
-  it 'should load profiles from YAML file' do
+  it 'should load profiles from profiles.yaml file' do
     write 'profiles.yaml', <<-YAML
+dev:
+  foo: bar
+test:
+  bar: baz
+    YAML
+    Buildr.profiles.should == { 'dev'=> { 'foo'=>'bar' }, 'test'=>{ 'bar'=>'baz' } }
+  end
+
+  it 'should load profiles from Profiles.yaml file' do
+    write 'Profiles.yaml', <<-YAML
 dev:
   foo: bar
 test:

Modified: incubator/buildr/trunk/spec/compile_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/compile_spec.rb?rev=612391&r1=612390&r2=612391&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/compile_spec.rb (original)
+++ incubator/buildr/trunk/spec/compile_spec.rb Wed Jan 16 01:11:40 2008
@@ -41,10 +41,10 @@
     compile_task.with('test.jar').should be(compile_task)
   end
 
-  it 'should respond to with() and add classpath dependencies' do
+  it 'should respond to with() and add dependencies' do
     jars = (1..3).map { |i| "test#{i}.jar" }
     compile_task.with *jars
-    compile_task.classpath.should == artifacts(jars)
+    compile_task.dependencies.should == artifacts(jars)
   end
 
   it 'should respond to into() and return self' do

Modified: incubator/buildr/trunk/spec/java_packaging_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/java_packaging_spec.rb?rev=612391&r1=612390&r2=612391&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/java_packaging_spec.rb (original)
+++ incubator/buildr/trunk/spec/java_packaging_spec.rb Wed Jan 16 01:11:40 2008
@@ -9,8 +9,7 @@
   end
 
   it 'should include JDK version' do
-    Java.stub!(:version).and_return '1.6_6'
-    define('foo').manifest['Build-Jdk'].should eql('1.6_6')
+    define('foo').manifest['Build-Jdk'].should =~ /^1\.\d+\.\w+$/
   end
 
   it 'should include project comment' do
@@ -75,11 +74,11 @@
     inspect_manifest do |sections|
       sections.size.should be(1)
       sections.first.should == {
-        'Manifest-Version'        => '1.0',
-        'Created-By'              => 'Buildr',
+        'Manifest-Version'        =>'1.0',
+        'Created-By'              =>'Buildr',
         'Implementation-Title'    =>@project.name,
         'Implementation-Version'  =>'1.2',
-        'Build-Jdk'               =>Java.version,
+        'Build-Jdk'               =>ENV_JAVA['java.version'],
         'Build-By'                =>'MysteriousJoe'
       }
     end

Modified: incubator/buildr/trunk/spec/spec_helpers.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/spec_helpers.rb?rev=612391&r1=612390&r2=612391&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/spec_helpers.rb (original)
+++ incubator/buildr/trunk/spec/spec_helpers.rb Wed Jan 16 01:11:40 2008
@@ -1,6 +1,6 @@
 # This file gets loaded twice when running 'spec spec/*' and not with pleasent results,
 # so ignore the second attempt to load it.
-unless $LOADED_FEATURES.include?(__FILE__)
+unless self.class.const_defined?('SpecHelpers')
 
   require 'rubygems'
   $LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__))
@@ -260,4 +260,5 @@
     # Sanbdox Rake/Buildr for each test.
     config.include Sandbox
   end
+
 end