buildr 1.3.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. data/CHANGELOG +780 -0
  2. data/DISCLAIMER +7 -0
  3. data/KEYS +151 -0
  4. data/LICENSE +176 -0
  5. data/NOTICE +31 -0
  6. data/README +173 -0
  7. data/Rakefile +63 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +232 -0
  10. data/addon/buildr/hibernate.rb +142 -0
  11. data/addon/buildr/javacc.rb +85 -0
  12. data/addon/buildr/jdepend.rb +60 -0
  13. data/addon/buildr/jetty.rb +248 -0
  14. data/addon/buildr/nailgun.rb +892 -0
  15. data/addon/buildr/openjpa.rb +90 -0
  16. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  17. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  18. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  19. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  20. data/addon/buildr/xmlbeans.rb +93 -0
  21. data/bin/buildr +21 -0
  22. data/buildr.gemspec +50 -0
  23. data/doc/css/default.css +225 -0
  24. data/doc/css/print.css +95 -0
  25. data/doc/css/syntax.css +43 -0
  26. data/doc/images/apache-incubator-logo.png +0 -0
  27. data/doc/images/buildr-hires.png +0 -0
  28. data/doc/images/buildr.png +0 -0
  29. data/doc/images/note.png +0 -0
  30. data/doc/images/tip.png +0 -0
  31. data/doc/images/zbuildr.tif +0 -0
  32. data/doc/pages/artifacts.textile +317 -0
  33. data/doc/pages/building.textile +501 -0
  34. data/doc/pages/contributing.textile +178 -0
  35. data/doc/pages/download.textile +25 -0
  36. data/doc/pages/extending.textile +229 -0
  37. data/doc/pages/getting_started.textile +337 -0
  38. data/doc/pages/index.textile +63 -0
  39. data/doc/pages/mailing_lists.textile +17 -0
  40. data/doc/pages/more_stuff.textile +367 -0
  41. data/doc/pages/packaging.textile +592 -0
  42. data/doc/pages/projects.textile +449 -0
  43. data/doc/pages/recipes.textile +127 -0
  44. data/doc/pages/settings_profiles.textile +339 -0
  45. data/doc/pages/testing.textile +475 -0
  46. data/doc/pages/troubleshooting.textile +121 -0
  47. data/doc/pages/whats_new.textile +389 -0
  48. data/doc/print.haml +52 -0
  49. data/doc/print.toc.yaml +28 -0
  50. data/doc/scripts/buildr-git.rb +411 -0
  51. data/doc/scripts/install-jruby.sh +44 -0
  52. data/doc/scripts/install-linux.sh +64 -0
  53. data/doc/scripts/install-osx.sh +52 -0
  54. data/doc/site.haml +55 -0
  55. data/doc/site.toc.yaml +44 -0
  56. data/lib/buildr.rb +47 -0
  57. data/lib/buildr/core.rb +27 -0
  58. data/lib/buildr/core/application.rb +373 -0
  59. data/lib/buildr/core/application_cli.rb +134 -0
  60. data/lib/buildr/core/build.rb +262 -0
  61. data/lib/buildr/core/checks.rb +382 -0
  62. data/lib/buildr/core/common.rb +155 -0
  63. data/lib/buildr/core/compile.rb +594 -0
  64. data/lib/buildr/core/environment.rb +120 -0
  65. data/lib/buildr/core/filter.rb +258 -0
  66. data/lib/buildr/core/generate.rb +195 -0
  67. data/lib/buildr/core/help.rb +118 -0
  68. data/lib/buildr/core/progressbar.rb +156 -0
  69. data/lib/buildr/core/project.rb +890 -0
  70. data/lib/buildr/core/test.rb +690 -0
  71. data/lib/buildr/core/transports.rb +486 -0
  72. data/lib/buildr/core/util.rb +235 -0
  73. data/lib/buildr/ide.rb +19 -0
  74. data/lib/buildr/ide/eclipse.rb +181 -0
  75. data/lib/buildr/ide/idea.ipr.template +300 -0
  76. data/lib/buildr/ide/idea.rb +194 -0
  77. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  78. data/lib/buildr/ide/idea7x.rb +210 -0
  79. data/lib/buildr/java.rb +26 -0
  80. data/lib/buildr/java/ant.rb +71 -0
  81. data/lib/buildr/java/bdd_frameworks.rb +267 -0
  82. data/lib/buildr/java/commands.rb +210 -0
  83. data/lib/buildr/java/compilers.rb +432 -0
  84. data/lib/buildr/java/deprecated.rb +141 -0
  85. data/lib/buildr/java/groovyc.rb +137 -0
  86. data/lib/buildr/java/jruby.rb +99 -0
  87. data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
  88. data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
  89. data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
  90. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  91. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
  92. data/lib/buildr/java/packaging.rb +706 -0
  93. data/lib/buildr/java/pom.rb +178 -0
  94. data/lib/buildr/java/rjb.rb +142 -0
  95. data/lib/buildr/java/test_frameworks.rb +290 -0
  96. data/lib/buildr/java/version_requirement.rb +172 -0
  97. data/lib/buildr/packaging.rb +21 -0
  98. data/lib/buildr/packaging/artifact.rb +729 -0
  99. data/lib/buildr/packaging/artifact_namespace.rb +957 -0
  100. data/lib/buildr/packaging/artifact_search.rb +140 -0
  101. data/lib/buildr/packaging/gems.rb +102 -0
  102. data/lib/buildr/packaging/package.rb +233 -0
  103. data/lib/buildr/packaging/tar.rb +104 -0
  104. data/lib/buildr/packaging/zip.rb +719 -0
  105. data/rakelib/apache.rake +126 -0
  106. data/rakelib/changelog.rake +56 -0
  107. data/rakelib/doc.rake +103 -0
  108. data/rakelib/package.rake +44 -0
  109. data/rakelib/release.rake +53 -0
  110. data/rakelib/rspec.rake +81 -0
  111. data/rakelib/rubyforge.rake +45 -0
  112. data/rakelib/scm.rake +49 -0
  113. data/rakelib/setup.rake +59 -0
  114. data/rakelib/stage.rake +45 -0
  115. data/spec/application_spec.rb +316 -0
  116. data/spec/archive_spec.rb +494 -0
  117. data/spec/artifact_namespace_spec.rb +635 -0
  118. data/spec/artifact_spec.rb +738 -0
  119. data/spec/build_spec.rb +193 -0
  120. data/spec/checks_spec.rb +537 -0
  121. data/spec/common_spec.rb +579 -0
  122. data/spec/compile_spec.rb +561 -0
  123. data/spec/groovy_compilers_spec.rb +239 -0
  124. data/spec/java_bdd_frameworks_spec.rb +238 -0
  125. data/spec/java_compilers_spec.rb +446 -0
  126. data/spec/java_packaging_spec.rb +1042 -0
  127. data/spec/java_test_frameworks_spec.rb +414 -0
  128. data/spec/packaging_helper.rb +63 -0
  129. data/spec/packaging_spec.rb +589 -0
  130. data/spec/project_spec.rb +739 -0
  131. data/spec/sandbox.rb +116 -0
  132. data/spec/scala_compilers_spec.rb +239 -0
  133. data/spec/spec.opts +6 -0
  134. data/spec/spec_helpers.rb +283 -0
  135. data/spec/test_spec.rb +871 -0
  136. data/spec/transport_spec.rb +300 -0
  137. data/spec/version_requirement_spec.rb +115 -0
  138. metadata +324 -0
@@ -0,0 +1,45 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ begin
18
+ require 'rubyforge'
19
+ rescue LoadError
20
+ puts 'Please run rake setup to install the RubyForge gem'
21
+ task 'setup' do
22
+ install_gem 'rubyforge'
23
+ end
24
+ task 'release:check' do
25
+ fail 'Please run rake setup to install the RubyForge gem'
26
+ end
27
+ end
28
+
29
+
30
+ namespace 'rubyforge' do
31
+
32
+ task 'release'=>'published' do |task|
33
+ changes = FileList['published/CHANGES'].first
34
+ files = FileList['published/*.{gem,tgz,zip}'].exclude(changes).existing
35
+ print "Uploading #{spec.version} to RubyForge ... "
36
+ rubyforge = RubyForge.new
37
+ rubyforge.login
38
+ rubyforge.userconfig.merge!('release_changes'=>changes, 'preformatted' => true) if changes
39
+ rubyforge.add_release spec.rubyforge_project.downcase, spec.name.downcase, spec.version, *files
40
+ puts 'Done'
41
+ end
42
+
43
+ end
44
+
45
+ task 'release:publish'=>'rubyforge:release'
@@ -0,0 +1,49 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ # Handling of source control.
18
+ namespace 'scm' do
19
+
20
+ task 'check' do
21
+ print 'Checking there are no local changes ... '
22
+ svn = `svn status`
23
+ fail "Cannot release unless all local changes are in SVN:\n#{svn}" unless svn.empty?
24
+ git = `git status`
25
+ fail "Cannot release unless all local changes are in Git:\n#{git}" if git[/^#\t/]
26
+ puts 'OK'
27
+ end
28
+
29
+ task 'tag' do
30
+ info = `svn info` + `git svn info` # Using either svn or git-svn
31
+ url = info[/^URL:/] && info.scan(/^URL: (.*)/)[0][0]
32
+ break unless url
33
+ new_url = url.sub(/(trunk$)|(branches\/\w*)$/, "tags/#{spec.version}")
34
+ break if url == new_url
35
+ print "Tagging release as tags/#{spec.version} ... "
36
+ sh 'svn', 'copy', url, new_url, '-m', "Release #{spec.version}", :verbose=>false do |ok, res|
37
+ if ok
38
+ puts 'Done'
39
+ else
40
+ puts 'Could not create tag, please do it yourself!'
41
+ puts %{ svn copy #{url} #{new_url} -m "#{spec.version}"}
42
+ end
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ task 'stage:check'=>'scm:check'
49
+ task 'release:wrapup'=>'scm:tag'
@@ -0,0 +1,59 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+ # True if running on the Windows operating sytem. Different from Gem.win_platform?
16
+ # which returns true if running on the Windows platform of MRI, false when using JRuby.
17
+
18
+
19
+ require 'rubygems/source_info_cache'
20
+
21
+
22
+ def windows?
23
+ Config::CONFIG['host_os'] =~ /windows|cygwin|bccwin|cygwin|djgpp|mingw|mswin|wince/i
24
+ end
25
+
26
+
27
+ # Finds and returns path to executable. Consults PATH environment variable.
28
+ # Returns nil if executable not found.
29
+ def which(name)
30
+ if windows?
31
+ path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| path.gsub('\\', '/') }.map { |path| "#{path}/#{name}.{exe,bat,com}" }
32
+ else
33
+ path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| "#{path}/#{name}" }
34
+ end
35
+ FileList[path].existing.first
36
+ end
37
+
38
+
39
+ def install_gem(name, ver_requirement = nil)
40
+ dep = Gem::Dependency.new(name, ver_requirement)
41
+ if Gem::SourceIndex.from_installed_gems.search(dep).empty?
42
+ spec = Gem::SourceInfoCache.search(dep).last
43
+ fail "#{dep} not found in local or remote repository!" unless spec
44
+ puts "Installing #{spec} ..."
45
+ args = [Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', spec.name, '-v', spec.version.to_s]
46
+ args.unshift('sudo', 'env', 'JAVA_HOME=' + ENV['JAVA_HOME']) unless windows?
47
+ sh *args
48
+ end
49
+ end
50
+
51
+ # Setup environment for running this Rakefile (RSpec, Docter, etc).
52
+ desc "If you're building from sources, run this task one to setup the necessary dependencies."
53
+ missing = spec.dependencies.select { |dep| Gem::SourceIndex.from_installed_gems.search(dep).empty? }
54
+ task 'setup' do
55
+ missing.each do |dep|
56
+ install_gem dep.name, dep.version_requirements
57
+ end
58
+ end
59
+ puts "Missing Gems #{missing.join(', ')}, please run rake setup first!" unless missing.empty?
@@ -0,0 +1,45 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ # Staged files are copied to this directory first, and from there uploaded to the staging server.
18
+ directory 'staged'
19
+
20
+ task 'clobber' do
21
+ rm_rf 'staged'
22
+ end
23
+
24
+ namespace 'stage' do
25
+ # stage:check verifies that we're able to stage a release: check for a changelog,
26
+ # local changes, run all the test cases, etc. You can add more actions, e.g.
27
+ # checking license files, spell checking documentation.
28
+ task 'check'=>['setup', 'clobber']
29
+
30
+ # stage:prepare prepares all the files necessary for making a successful release:
31
+ # binary and source packages, documentation, Web site, change file, checksums, etc.
32
+ # This task depends on stage:check, and also performs its own verification of the
33
+ # produced artifacts. Staged files are placed in the staged directory.
34
+ task 'prepare'=>'staged'
35
+
36
+ # stage:upload moves the stage directory to the staging server.
37
+ task 'upload' do |task, args|
38
+ puts "Uploading staged directory to #{args.staging} ..."
39
+ sh 'rsync', '--progress', '--recursive', 'staged/', args.staging
40
+ puts 'Done'
41
+ end
42
+ end
43
+
44
+ desc 'Stage files for the release, upload them to staging server'
45
+ task 'stage'=>['stage:check', 'stage:prepare', 'stage:upload']
@@ -0,0 +1,316 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require File.join(File.dirname(__FILE__), 'spec_helpers')
18
+
19
+
20
+ describe Buildr::Application do
21
+
22
+ describe 'home_dir' do
23
+ it 'should point to ~/.buildr' do
24
+ Buildr.application.home_dir.should eql(File.expand_path('.buildr', ENV['HOME']))
25
+ end
26
+
27
+ it 'should point to existing directory' do
28
+ File.directory?(Buildr.application.home_dir).should be_true
29
+ end
30
+ end
31
+
32
+ describe 'environment' do
33
+ it 'should return value of BUILDR_ENV' do
34
+ ENV['BUILDR_ENV'] = 'qa'
35
+ Buildr::Application.new.environment.should eql('qa')
36
+ end
37
+
38
+ it 'should default to development' do
39
+ Buildr::Application.new.environment.should eql('development')
40
+ end
41
+
42
+ it 'should set environment name from -e argument' do
43
+ ARGV.push('-e', 'test')
44
+ Buildr::Application.new.environment.should eql('test')
45
+ ENV['BUILDR_ENV'].should eql('test')
46
+ end
47
+
48
+ after do
49
+ ENV['BUILDR_ENV'] = nil
50
+ end
51
+ end
52
+
53
+ describe 'gems' do
54
+
55
+ def load_with_yaml
56
+ write 'build.yaml', <<-YAML
57
+ gems:
58
+ - rspec
59
+ - rake >= 0.8
60
+ YAML
61
+ Buildr.application.load_gems
62
+ end
63
+
64
+ it 'should return empty array if no gems specified' do
65
+ Buildr.application.load_gems
66
+ Buildr.application.gems.should be_empty
67
+ end
68
+
69
+ it 'should return one entry for each gem specified in buildr.yaml' do
70
+ load_with_yaml
71
+ Buildr.application.gems.size.should be(2)
72
+ end
73
+
74
+ it 'should return a Gem::Specification for each installed gem' do
75
+ load_with_yaml
76
+ Buildr.application.gems.each { |gem| gem.should be_kind_of(Gem::Specification) }
77
+ end
78
+
79
+ it 'should parse Gem name correctly' do
80
+ load_with_yaml
81
+ Buildr.application.gems.map(&:name).should include('rake', 'rspec')
82
+ end
83
+
84
+ it 'should find installed version of Gem' do
85
+ load_with_yaml
86
+ Buildr.application.gems.each { |gem| gem.version.should eql(Gem.loaded_specs[gem.name].version) }
87
+ end
88
+ end
89
+
90
+
91
+ describe 'load_gems' do
92
+ before do
93
+ @spec = Gem::Specification.new do |spec|
94
+ spec.name = 'foo'
95
+ spec.version = '1.2'
96
+ end
97
+ end
98
+
99
+ it 'should do nothing if no gems specified' do
100
+ lambda { Buildr.application.load_gems }.should_not raise_error
101
+ end
102
+
103
+ it 'should install nothing if specified gems already installed' do
104
+ Buildr.application.should_receive(:listed_gems).and_return([Gem.loaded_specs['rspec']])
105
+ Util.should_not_receive(:ruby)
106
+ lambda { Buildr.application.load_gems }.should_not raise_error
107
+ end
108
+
109
+ it 'should fail if required gem not found in remote repository' do
110
+ Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
111
+ Gem::SourceInfoCache.should_receive(:search).and_return([])
112
+ lambda { Buildr.application.load_gems }.should raise_error(LoadError, /cannot be found/i)
113
+ end
114
+
115
+ it 'should fail if need to install gem and not running in interactive mode' do
116
+ Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
117
+ Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
118
+ $stdout.should_receive(:isatty).and_return(false)
119
+ lambda { Buildr.application.load_gems }.should raise_error(LoadError, /this build requires the gems/i)
120
+ end
121
+
122
+ it 'should ask permission before installing required gems' do
123
+ Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
124
+ Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
125
+ $terminal.should_receive(:agree).with(/install/, true)
126
+ lambda { Buildr.application.load_gems }.should raise_error
127
+ end
128
+
129
+ it 'should fail if permission not granted to install gem' do
130
+ Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
131
+ Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
132
+ $terminal.should_receive(:agree).and_return(false)
133
+ lambda { Buildr.application.load_gems }.should raise_error(LoadError, /cannot build without/i)
134
+ end
135
+
136
+ it 'should install gem if permission granted' do
137
+ Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
138
+ Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
139
+ $terminal.should_receive(:agree).and_return(true)
140
+ Util.should_receive(:ruby) do |*args|
141
+ args.should include('install', 'foo', '-v', '1.2')
142
+ end
143
+ Buildr.application.should_receive(:gem).and_return(false)
144
+ Buildr.application.load_gems
145
+ end
146
+
147
+ it 'should reload gem cache after installing required gems' do
148
+ Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
149
+ Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
150
+ $terminal.should_receive(:agree).and_return(true)
151
+ Util.should_receive(:ruby)
152
+ Gem.source_index.should_receive(:load_gems_in).with(Gem::SourceIndex.installed_spec_directories)
153
+ Buildr.application.should_receive(:gem).and_return(false)
154
+ Buildr.application.load_gems
155
+ end
156
+
157
+ it 'should load previously installed gems' do
158
+ Buildr.application.should_receive(:listed_gems).and_return([Gem.loaded_specs['rspec']])
159
+ Buildr.application.should_receive(:gem).with('rspec', Gem.loaded_specs['rspec'].version.to_s)
160
+ Buildr.application.load_gems
161
+ end
162
+
163
+ it 'should load newly installed gems' do
164
+ Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
165
+ Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
166
+ $terminal.should_receive(:agree).and_return(true)
167
+ Util.should_receive(:ruby)
168
+ Buildr.application.should_receive(:gem).with('foo', @spec.version.to_s)
169
+ Buildr.application.load_gems
170
+ end
171
+
172
+ it 'should default to >=0 version requirement if not specified' do
173
+ write 'build.yaml', 'gems: foo'
174
+ Gem::SourceInfoCache.should_receive(:search).with(Gem::Dependency.new('foo', '>=0')).and_return([])
175
+ lambda { Buildr.application.load_gems }.should raise_error
176
+ end
177
+
178
+ it 'should parse exact version requirement' do
179
+ write 'build.yaml', 'gems: foo 2.5'
180
+ Gem::SourceInfoCache.should_receive(:search).with(Gem::Dependency.new('foo', '=2.5')).and_return([])
181
+ lambda { Buildr.application.load_gems }.should raise_error
182
+ end
183
+
184
+ it 'should parse range version requirement' do
185
+ write 'build.yaml', 'gems: foo ~>2.3'
186
+ Gem::SourceInfoCache.should_receive(:search).with(Gem::Dependency.new('foo', '~>2.3')).and_return([])
187
+ lambda { Buildr.application.load_gems }.should raise_error
188
+ end
189
+
190
+ it 'should parse multiple version requirements' do
191
+ write 'build.yaml', 'gems: foo >=2.0 !=2.1'
192
+ Gem::SourceInfoCache.should_receive(:search).with(Gem::Dependency.new('foo', ['>=2.0', '!=2.1'])).and_return([])
193
+ lambda { Buildr.application.load_gems }.should raise_error
194
+ end
195
+ end
196
+
197
+ end
198
+
199
+
200
+ describe Buildr, 'settings' do
201
+
202
+ describe 'user' do
203
+
204
+ it 'should be empty hash if no settings.yaml file' do
205
+ Buildr.settings.user.should == {}
206
+ end
207
+
208
+ it 'should return loaded settings.yaml file' do
209
+ write 'home/.buildr/settings.yaml', 'foo: bar'
210
+ Buildr.settings.user.should == { 'foo'=>'bar' }
211
+ end
212
+
213
+ it 'should fail if settings.yaml file is not a hash' do
214
+ write 'home/.buildr/settings.yaml', 'foo bar'
215
+ lambda { Buildr.settings.user }.should raise_error(RuntimeError, /expecting.*settings.yaml/i)
216
+ end
217
+
218
+ it 'should be empty hash if settings.yaml file is empty' do
219
+ write 'home/.buildr/settings.yaml'
220
+ Buildr.settings.user.should == {}
221
+ end
222
+ end
223
+
224
+ describe 'configuration' do
225
+ it 'should be empty hash if no build.yaml file' do
226
+ Buildr.settings.build.should == {}
227
+ end
228
+
229
+ it 'should return loaded build.yaml file' do
230
+ write 'build.yaml', 'foo: bar'
231
+ Buildr.settings.build.should == { 'foo'=>'bar' }
232
+ end
233
+
234
+ it 'should fail if build.yaml file is not a hash' do
235
+ write 'build.yaml', 'foo bar'
236
+ lambda { Buildr.settings.build }.should raise_error(RuntimeError, /expecting.*build.yaml/i)
237
+ end
238
+
239
+ it 'should be empty hash if build.yaml file is empty' do
240
+ write 'build.yaml'
241
+ Buildr.settings.build.should == {}
242
+ end
243
+ end
244
+
245
+ describe 'profiles' do
246
+ it 'should be empty hash if no profiles.yaml file' do
247
+ Buildr.settings.profiles.should == {}
248
+ end
249
+
250
+ it 'should return loaded profiles.yaml file' do
251
+ write 'profiles.yaml', <<-YAML
252
+ development:
253
+ foo: bar
254
+ YAML
255
+ Buildr.settings.profiles.should == { 'development'=> { 'foo'=>'bar' } }
256
+ end
257
+
258
+ it 'should fail if profiles.yaml file is not a hash' do
259
+ write 'profiles.yaml', 'foo bar'
260
+ lambda { Buildr.settings.profiles }.should raise_error(RuntimeError, /expecting.*profiles.yaml/i)
261
+ end
262
+
263
+ it 'should be empty hash if profiles.yaml file is empty' do
264
+ write 'profiles.yaml'
265
+ Buildr.settings.profiles.should == {}
266
+ end
267
+ end
268
+
269
+ describe 'profile' do
270
+ it 'should be empty hash if no profiles.yaml' do
271
+ Buildr.settings.profile.should == {}
272
+ end
273
+
274
+ it 'should be empty hash if no matching profile' do
275
+ write 'profiles.yaml', <<-YAML
276
+ test:
277
+ foo: bar
278
+ YAML
279
+ Buildr.settings.profile.should == {}
280
+ end
281
+
282
+ it 'should return profile matching environment name' do
283
+ write 'profiles.yaml', <<-YAML
284
+ development:
285
+ foo: bar
286
+ test:
287
+ foo: baz
288
+ YAML
289
+ Buildr.settings.profile.should == { 'foo'=>'bar' }
290
+ end
291
+
292
+ end
293
+
294
+ end
295
+
296
+
297
+ describe Buildr do
298
+
299
+ describe 'environment' do
300
+ it 'should be same as Buildr.application.environment' do
301
+ Buildr.environment.should eql(Buildr.application.environment)
302
+ end
303
+ end
304
+
305
+ describe 'application' do
306
+ it 'should be same as Rake.application' do
307
+ Buildr.application.should == Rake.application
308
+ end
309
+ end
310
+
311
+ describe 'settings' do
312
+ it 'should be same as Buildr.application.settings' do
313
+ Buildr.settings.should == Buildr.application.settings
314
+ end
315
+ end
316
+ end