Author: assaf
Date: Thu Oct 16 18:02:14 2008
New Revision: 705439
URL: http://svn.apache.org/viewvc?rev=705439&view=rev
Log:
Now with fixed specs, all tests are green.
Modified:
incubator/buildr/trunk/lib/buildr/core/application.rb
incubator/buildr/trunk/spec/core/application_spec.rb
incubator/buildr/trunk/spec/core/project_spec.rb
incubator/buildr/trunk/spec/packaging/artifact_spec.rb
incubator/buildr/trunk/spec/sandbox.rb
incubator/buildr/trunk/spec/spec_helpers.rb
Modified: incubator/buildr/trunk/lib/buildr/core/application.rb
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core/application.rb?rev=705439&r1=705438&r2=705439&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/application.rb (original)
+++ incubator/buildr/trunk/lib/buildr/core/application.rb Thu Oct 16 18:02:14
2008
@@ -151,7 +151,9 @@
attr_reader :home_dir
# Copied from BUILD_ENV.
- attr_reader :environment
+ def environment
+ ENV['BUILDR_ENV']
+ end
# Returns the Settings associated with this build.
def settings
@@ -256,7 +258,6 @@
standard_buildr_options.each { |args| opts.on(*args) }
parsed_argv = opts.parse(ARGV)
- @environment = ENV['BUILDR_ENV'] ||= 'development'
parsed_argv
end
Modified: incubator/buildr/trunk/spec/core/application_spec.rb
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/core/application_spec.rb?rev=705439&r1=705438&r2=705439&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/core/application_spec.rb (original)
+++ incubator/buildr/trunk/spec/core/application_spec.rb Thu Oct 16 18:02:14
2008
@@ -31,44 +31,58 @@
describe '#run' do
it 'should execute *_load methods in order' do
- last = nil
- order = [:find_buildfile, :load_gems, :load_artifacts, :load_tasks,
- :load_requires, :load_buildfile, :load_imports, :top_level]
+ order = [:load_gems, :load_artifact_ns, :load_tasks, :raw_load_buildfile]
order.each { |method| Buildr.application.should_receive(method).ordered }
Buildr.application.stub!(:exit) # With this, shows the correct error
instead of SystemExit.
Buildr.application.run
end
+
+ it 'should load imports after loading buildfile' do
+ method = Buildr.application.method(:raw_load_buildfile)
+ Buildr.application.should_receive(:raw_load_buildfile) do
+ Buildr.application.should_receive(:load_imports)
+ method.call
+ end
+ Buildr.application.stub!(:exit) # With this, shows the correct error
instead of SystemExit.
+ Buildr.application.run
+ end
+
+ it 'should evaluate all projects after loading buildfile' do
+ Buildr.application.should_receive(:load_imports) do
+ Buildr.should_receive(:projects)
+ end
+ Buildr.application.stub!(:exit) # With this, shows the correct error
instead of SystemExit.
+ Buildr.application.run
+ end
end
describe 'environment' do
it 'should return value of BUILDR_ENV' do
ENV['BUILDR_ENV'] = 'qa'
- Buildr::Application.new.environment.should eql('qa')
+ Buildr.application.environment.should eql('qa')
end
it 'should default to development' do
- Buildr::Application.new.environment.should eql('development')
+ Buildr.application.environment.should eql('development')
end
it 'should set environment name from -e argument' do
ARGV.push('-e', 'test')
- Buildr::Application.new.environment.should eql('test')
+ Buildr.application.send(:handle_options)
+ Buildr.application.environment.should eql('test')
ENV['BUILDR_ENV'].should eql('test')
end
it 'should be echoed to user' do
write 'buildfile'
- lambda { Buildr.application.send :load_buildfile }.should
show_info(%r{(in .*, development)})
- end
-
- after do
- ENV['BUILDR_ENV'] = nil
+ ENV['BUILDR_ENV'] = 'spec'
+ Buildr.application.send(:handle_options)
+ lambda { Buildr.application.send :load_buildfile }.should show(%r{(in
.*, spec)})
end
end
describe 'gems' do
before do
- Buildr.application.private_methods(true).should include('load_gems')
class << Buildr.application
public :load_gems
end
@@ -112,7 +126,6 @@
describe 'load_gems' do
before do
- Buildr.application.private_methods(true).should include('load_gems')
class << Buildr.application
public :load_gems
end
@@ -312,6 +325,9 @@
end
describe 'profile' do
+ before do
+ end
+
it 'should be empty hash if no profiles.yaml' do
Buildr.settings.profile.should == {}
end
@@ -376,15 +392,6 @@
Buildr.application.send :load_tasks
Buildr.application.buildfile.timestamp.should be_close(@buildfile_time +
5, 1)
end
-
- it 'should include explicitly required files as dependencies' do
- write 'some/file.rb'; File.utime(@buildfile_time + 5, @buildfile_time +
5, 'some/file.rb')
- Buildr.application.instance_variable_set(:@requires, ['rbconfig',
'some/file.rb'])
- Buildr.application.send :load_buildfile
- Buildr.application.buildfile.timestamp.should be_close(@buildfile_time +
5, 1)
- Buildr.application.buildfile.prerequisites.should
include(File.expand_path('some/file.rb'))
- Buildr.application.buildfile.prerequisites.should_not include('rbconfig')
- end
end
end
Modified: incubator/buildr/trunk/spec/core/project_spec.rb
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/core/project_spec.rb?rev=705439&r1=705438&r2=705439&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/core/project_spec.rb (original)
+++ incubator/buildr/trunk/spec/core/project_spec.rb Thu Oct 16 18:02:14 2008
@@ -747,12 +747,3 @@
end
end
=end
-
-
-describe Rake::Task, 'buildr:initialize' do
- it 'should evaluate all project definitions' do
- defined = false
- Buildr.define('foo') { defined = true }
- lambda { task('buildr:initialize').invoke }.should change { defined
}.to(true)
- end
-end
Modified: incubator/buildr/trunk/spec/packaging/artifact_spec.rb
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/packaging/artifact_spec.rb?rev=705439&r1=705438&r2=705439&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/packaging/artifact_spec.rb (original)
+++ incubator/buildr/trunk/spec/packaging/artifact_spec.rb Thu Oct 16 18:02:14
2008
@@ -430,7 +430,7 @@
artifacts:
j2ee: geronimo-spec:geronimo-spec-j2ee:jar:1.4-rc4
YAML
- Buildr.application.send :load_artifacts
+ Buildr.application.send(:load_artifact_ns)
artifact(:j2ee).to_s.pathmap('%f').should ==
'geronimo-spec-j2ee-1.4-rc4.jar'
end
end
Modified: incubator/buildr/trunk/spec/sandbox.rb
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/sandbox.rb?rev=705439&r1=705438&r2=705439&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/sandbox.rb (original)
+++ incubator/buildr/trunk/spec/sandbox.rb Thu Oct 16 18:02:14 2008
@@ -72,10 +72,11 @@
# for projects, compilation. We need a place that does not depend
# on the current directory.
@_sandbox[:original_dir] = Dir.pwd
- temp = File.join(File.dirname(__FILE__), '../tmp')
- FileUtils.mkpath temp
- Dir.chdir temp
+ @temp = File.join(File.dirname(__FILE__), '../tmp')
+ FileUtils.mkpath @temp
+ Dir.chdir @temp
+ ARGV.clear
Buildr.application = Buildr::Application.new
Sandbox.tasks.each { |block| block.call }
Buildr.application.instance_variable_set :@rules, Sandbox.rules.clone
@@ -95,6 +96,7 @@
@_sandbox[:artifacts] = Artifact.class_eval { @artifacts }.clone
Buildr.repositories.local = File.expand_path('repository')
ENV['HOME'] = File.expand_path('home')
+ ENV['BUILDR_ENV'] = 'development'
@_sandbox[:env_keys] = ENV.keys
['DEBUG', 'TEST', 'HTTP_PROXY', 'USER'].each { |k| ENV.delete(k) ;
ENV.delete(k.downcase) }
@@ -122,7 +124,7 @@
$LOAD_PATH.replace @_sandbox[:load_path]
$LOADED_FEATURES.replace @_sandbox[:loaded_features]
- FileUtils.rm_rf Dir.pwd
+ FileUtils.rm_rf @temp
# Get rid of all artifacts.
@_sandbox[:artifacts].tap { |artifacts| Artifact.class_eval { @artifacts =
artifacts } }
Modified: incubator/buildr/trunk/spec/spec_helpers.rb
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/spec_helpers.rb?rev=705439&r1=705438&r2=705439&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/spec_helpers.rb (original)
+++ incubator/buildr/trunk/spec/spec_helpers.rb Thu Oct 16 18:02:14 2008
@@ -28,7 +28,7 @@
include Checks::Matchers
- [:info, :warn, :error].each do |severity|
+ [:info, :warn, :error, :puts].each do |severity|
::Object.class_eval do
define_method severity do |message|
$messages ||= {}
@@ -90,6 +90,13 @@
MessageWithSeverityMatcher.new :error, message
end
+ # Test if any message was shown (puts). You can use a string or regular
expression.
+ #
+ # For example:
+ # lambda { puts 'ze test' }.should show(/ze test/)
+ def show(message)
+ MessageWithSeverityMatcher.new :puts, message
+ end
class ::Rake::Task
alias :execute_without_a_record :execute