ittayd-buildr 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. data/CHANGELOG +915 -0
  2. data/DISCLAIMER +7 -0
  3. data/LICENSE +176 -0
  4. data/NOTICE +26 -0
  5. data/README.rdoc +146 -0
  6. data/Rakefile +64 -0
  7. data/_buildr +28 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +22 -0
  10. data/addon/buildr/drb.rb +281 -0
  11. data/addon/buildr/emma.rb +22 -0
  12. data/addon/buildr/hibernate.rb +142 -0
  13. data/addon/buildr/javacc.rb +85 -0
  14. data/addon/buildr/jdepend.rb +60 -0
  15. data/addon/buildr/jetty.rb +248 -0
  16. data/addon/buildr/jibx.rb +86 -0
  17. data/addon/buildr/nailgun.rb +221 -0
  18. data/addon/buildr/openjpa.rb +90 -0
  19. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  20. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  22. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  23. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  26. data/addon/buildr/path.rb +136 -0
  27. data/addon/buildr/xmlbeans.rb +93 -0
  28. data/bin/buildr +19 -0
  29. data/buildr.buildfile +53 -0
  30. data/buildr.gemspec +58 -0
  31. data/doc/css/default.css +228 -0
  32. data/doc/css/print.css +100 -0
  33. data/doc/css/syntax.css +52 -0
  34. data/doc/images/apache-incubator-logo.png +0 -0
  35. data/doc/images/buildr-hires.png +0 -0
  36. data/doc/images/buildr.png +0 -0
  37. data/doc/images/favicon.png +0 -0
  38. data/doc/images/growl-icon.tiff +0 -0
  39. data/doc/images/note.png +0 -0
  40. data/doc/images/project-structure.png +0 -0
  41. data/doc/images/tip.png +0 -0
  42. data/doc/images/zbuildr.tif +0 -0
  43. data/doc/pages/artifacts.textile +207 -0
  44. data/doc/pages/building.textile +240 -0
  45. data/doc/pages/contributing.textile +208 -0
  46. data/doc/pages/download.textile +62 -0
  47. data/doc/pages/extending.textile +175 -0
  48. data/doc/pages/getting_started.textile +273 -0
  49. data/doc/pages/index.textile +42 -0
  50. data/doc/pages/languages.textile +407 -0
  51. data/doc/pages/mailing_lists.textile +17 -0
  52. data/doc/pages/more_stuff.textile +314 -0
  53. data/doc/pages/packaging.textile +427 -0
  54. data/doc/pages/projects.textile +274 -0
  55. data/doc/pages/recipes.textile +103 -0
  56. data/doc/pages/settings_profiles.textile +274 -0
  57. data/doc/pages/testing.textile +212 -0
  58. data/doc/pages/troubleshooting.textile +103 -0
  59. data/doc/pages/whats_new.textile +323 -0
  60. data/doc/print.haml +51 -0
  61. data/doc/print.toc.yaml +29 -0
  62. data/doc/scripts/buildr-git.rb +412 -0
  63. data/doc/scripts/install-jruby.sh +44 -0
  64. data/doc/scripts/install-linux.sh +64 -0
  65. data/doc/scripts/install-osx.sh +52 -0
  66. data/doc/site.haml +56 -0
  67. data/doc/site.toc.yaml +47 -0
  68. data/etc/KEYS +151 -0
  69. data/etc/git-svn-authors +16 -0
  70. data/lib/buildr/core/application.rb +665 -0
  71. data/lib/buildr/core/build.rb +311 -0
  72. data/lib/buildr/core/checks.rb +254 -0
  73. data/lib/buildr/core/common.rb +150 -0
  74. data/lib/buildr/core/compile.rb +590 -0
  75. data/lib/buildr/core/environment.rb +117 -0
  76. data/lib/buildr/core/filter.rb +366 -0
  77. data/lib/buildr/core/generate.rb +195 -0
  78. data/lib/buildr/core/help.rb +119 -0
  79. data/lib/buildr/core/osx.rb +49 -0
  80. data/lib/buildr/core/progressbar.rb +156 -0
  81. data/lib/buildr/core/project.rb +923 -0
  82. data/lib/buildr/core/test.rb +715 -0
  83. data/lib/buildr/core/transports.rb +560 -0
  84. data/lib/buildr/core/util.rb +294 -0
  85. data/lib/buildr/core.rb +29 -0
  86. data/lib/buildr/groovy/bdd.rb +106 -0
  87. data/lib/buildr/groovy/compiler.rb +138 -0
  88. data/lib/buildr/groovy.rb +18 -0
  89. data/lib/buildr/ide/eclipse.rb +222 -0
  90. data/lib/buildr/ide/idea.ipr.template +300 -0
  91. data/lib/buildr/ide/idea.rb +190 -0
  92. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  93. data/lib/buildr/ide/idea7x.rb +212 -0
  94. data/lib/buildr/ide.rb +19 -0
  95. data/lib/buildr/java/ant.rb +92 -0
  96. data/lib/buildr/java/bdd.rb +451 -0
  97. data/lib/buildr/java/cobertura.rb +236 -0
  98. data/lib/buildr/java/commands.rb +211 -0
  99. data/lib/buildr/java/compiler.rb +348 -0
  100. data/lib/buildr/java/deprecated.rb +141 -0
  101. data/lib/buildr/java/emma.rb +238 -0
  102. data/lib/buildr/java/jruby.rb +117 -0
  103. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  104. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  105. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +119 -0
  106. data/lib/buildr/java/packaging.rb +717 -0
  107. data/lib/buildr/java/pom.rb +174 -0
  108. data/lib/buildr/java/rjb.rb +155 -0
  109. data/lib/buildr/java/test_result.rb +307 -0
  110. data/lib/buildr/java/tests.rb +329 -0
  111. data/lib/buildr/java/version_requirement.rb +172 -0
  112. data/lib/buildr/java.rb +23 -0
  113. data/lib/buildr/packaging/archive.rb +488 -0
  114. data/lib/buildr/packaging/artifact.rb +759 -0
  115. data/lib/buildr/packaging/artifact_namespace.rb +972 -0
  116. data/lib/buildr/packaging/artifact_search.rb +140 -0
  117. data/lib/buildr/packaging/gems.rb +102 -0
  118. data/lib/buildr/packaging/package.rb +233 -0
  119. data/lib/buildr/packaging/tar.rb +186 -0
  120. data/lib/buildr/packaging/version_requirement.rb +172 -0
  121. data/lib/buildr/packaging/zip.rb +64 -0
  122. data/lib/buildr/packaging/ziptask.rb +313 -0
  123. data/lib/buildr/packaging.rb +24 -0
  124. data/lib/buildr/resources/buildr.icns +0 -0
  125. data/lib/buildr/scala/compiler.rb +109 -0
  126. data/lib/buildr/scala/tests.rb +203 -0
  127. data/lib/buildr/scala.rb +19 -0
  128. data/lib/buildr.rb +33 -0
  129. data/rakelib/apache.rake +191 -0
  130. data/rakelib/changelog.rake +57 -0
  131. data/rakelib/doc.rake +103 -0
  132. data/rakelib/package.rake +76 -0
  133. data/rakelib/release.rake +65 -0
  134. data/rakelib/rspec.rake +83 -0
  135. data/rakelib/rubyforge.rake +56 -0
  136. data/rakelib/scm.rake +49 -0
  137. data/rakelib/setup.rake +81 -0
  138. data/rakelib/stage.rake +48 -0
  139. data/spec/addon/drb_spec.rb +328 -0
  140. data/spec/core/application_spec.rb +419 -0
  141. data/spec/core/build_spec.rb +423 -0
  142. data/spec/core/checks_spec.rb +519 -0
  143. data/spec/core/common_spec.rb +670 -0
  144. data/spec/core/compile_spec.rb +582 -0
  145. data/spec/core/generate_spec.rb +33 -0
  146. data/spec/core/project_spec.rb +776 -0
  147. data/spec/core/test_spec.rb +1098 -0
  148. data/spec/core/transport_spec.rb +500 -0
  149. data/spec/groovy/bdd_spec.rb +80 -0
  150. data/spec/groovy/compiler_spec.rb +239 -0
  151. data/spec/ide/eclipse_spec.rb +311 -0
  152. data/spec/java/ant.rb +33 -0
  153. data/spec/java/bdd_spec.rb +358 -0
  154. data/spec/java/cobertura_spec.rb +77 -0
  155. data/spec/java/compiler_spec.rb +446 -0
  156. data/spec/java/emma_spec.rb +120 -0
  157. data/spec/java/java_spec.rb +96 -0
  158. data/spec/java/packaging_spec.rb +1120 -0
  159. data/spec/java/test_coverage_spec.rb +255 -0
  160. data/spec/java/tests_spec.rb +471 -0
  161. data/spec/packaging/archive_spec.rb +503 -0
  162. data/spec/packaging/artifact_namespace_spec.rb +646 -0
  163. data/spec/packaging/artifact_spec.rb +795 -0
  164. data/spec/packaging/packaging_helper.rb +63 -0
  165. data/spec/packaging/packaging_spec.rb +589 -0
  166. data/spec/sandbox.rb +139 -0
  167. data/spec/scala/compiler_spec.rb +228 -0
  168. data/spec/scala/tests_spec.rb +215 -0
  169. data/spec/spec_helpers.rb +327 -0
  170. data/spec/version_requirement_spec.rb +123 -0
  171. metadata +377 -0
@@ -0,0 +1,327 @@
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
+ # This file gets loaded twice when running 'spec spec/*' and not with pleasent results,
18
+ # so ignore the second attempt to load it.
19
+ unless defined?(SpecHelpers)
20
+
21
+ require 'rubygems'
22
+
23
+ # For testing we use the gem requirements specified on the buildr.gemspec
24
+ spec = Gem::Specification.load(File.expand_path('../buildr.gemspec', File.dirname(__FILE__)))
25
+ spec.dependencies.each { |dep| gem dep.name, dep.version_requirements.to_s }
26
+
27
+ # Make sure to load from these paths first, we don't want to load any
28
+ # code from Gem library.
29
+ $LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__)),
30
+ File.expand_path('../addon', File.dirname(__FILE__))
31
+
32
+ # Buildr uses autoload extensively, but autoload when running specs creates
33
+ # a problem -- we sandbox $LOADED_FEATURES, so we endup autoloading the same
34
+ # module twice. This turns autoload into a require, which is not the right
35
+ # thing, but will do for now.
36
+ def autoload(symbol, path)
37
+ require path
38
+ end
39
+ require 'buildr'
40
+
41
+ require File.expand_path('sandbox', File.dirname(__FILE__))
42
+
43
+ module SpecHelpers
44
+
45
+ include Checks::Matchers
46
+
47
+ [:info, :warn, :error, :puts].each do |severity|
48
+ ::Object.class_eval do
49
+ define_method severity do |message|
50
+ $messages ||= {}
51
+ ($messages[severity] ||= []) << message
52
+ end
53
+ end
54
+ end
55
+
56
+ class << Buildr.application
57
+ alias :deprecated_without_capture :deprecated
58
+ def deprecated(message)
59
+ verbose(true) { deprecated_without_capture message }
60
+ end
61
+ end
62
+
63
+ class MessageWithSeverityMatcher
64
+ def initialize(severity, message)
65
+ @severity = severity
66
+ @expect = message
67
+ end
68
+
69
+ def matches?(target)
70
+ $messages = {@severity => []}
71
+ target.call
72
+ return Regexp === @expect ? $messages[@severity].join('\n') =~ @expect : $messages[@severity].include?(@expect.to_s)
73
+ end
74
+
75
+ def failure_message
76
+ "Expected #{@severity} #{@expect.inspect}, " +
77
+ ($messages[@severity].empty? ? "no #{@severity} issued" : "found #{$messages[@severity].inspect}")
78
+ end
79
+
80
+ def negative_failure_message
81
+ "Found unexpected #{$messages[@severity].inspect}"
82
+ end
83
+ end
84
+
85
+ # Test if an info message was shown. You can use a string or regular expression.
86
+ #
87
+ # For example:
88
+ # lambda { info 'ze test' }.should show_info(/ze test/)
89
+ def show_info(message)
90
+ MessageWithSeverityMatcher.new :info, message
91
+ end
92
+
93
+ # Test if a warning was shown. You can use a string or regular expression.
94
+ #
95
+ # For example:
96
+ # lambda { warn 'ze test' }.should show_warning(/ze test/)
97
+ def show_warning(message)
98
+ MessageWithSeverityMatcher.new :warn, message
99
+ end
100
+
101
+ # Test if an error message was shown. You can use a string or regular expression.
102
+ #
103
+ # For example:
104
+ # lambda { error 'ze test' }.should show_error(/ze test/)
105
+ def show_error(message)
106
+ MessageWithSeverityMatcher.new :error, message
107
+ end
108
+
109
+ # Test if any message was shown (puts). You can use a string or regular expression.
110
+ #
111
+ # For example:
112
+ # lambda { puts 'ze test' }.should show(/ze test/)
113
+ def show(message)
114
+ MessageWithSeverityMatcher.new :puts, message
115
+ end
116
+
117
+ class ::Rake::Task
118
+ alias :execute_without_a_record :execute
119
+ def execute(args)
120
+ $executed ||= []
121
+ $executed << name
122
+ execute_without_a_record args
123
+ end
124
+ end
125
+
126
+ class InvokeMatcher
127
+ def initialize(*tasks)
128
+ @expecting = tasks.map { |task| [task].flatten.map(&:to_s) }
129
+ end
130
+
131
+ def matches?(target)
132
+ $executed = []
133
+ target.call
134
+ return false unless all_ran?
135
+ return !@but_not.any_ran? if @but_not
136
+ return true
137
+ end
138
+
139
+ def failure_message
140
+ return @but_not.negative_failure_message if all_ran? && @but_not
141
+ "Expected the tasks #{expected} to run, but #{remaining} did not run, or not in the order we expected them to." +
142
+ " Tasks that ran: #{$executed.inspect}"
143
+ end
144
+
145
+ def negative_failure_message
146
+ if all_ran?
147
+ "Expected the tasks #{expected} to not run, but they all ran."
148
+ else
149
+ "Expected the tasks #{expected} to not run, and all but #{remaining} ran."
150
+ end
151
+ end
152
+
153
+ def but_not(*tasks)
154
+ @but_not = InvokeMatcher.new(*tasks)
155
+ self
156
+ end
157
+
158
+ protected
159
+
160
+ def expected
161
+ @expecting.map { |tests| tests.join('=>') }.join(', ')
162
+ end
163
+
164
+ def remaining
165
+ @remaining.map { |tests| tests.join('=>') }.join(', ')
166
+ end
167
+
168
+ def all_ran?
169
+ @remaining ||= $executed.inject(@expecting) do |expecting, executed|
170
+ expecting.map { |tasks| tasks.first == executed ? tasks[1..-1] : tasks }.reject(&:empty?)
171
+ end
172
+ @remaining.empty?
173
+ end
174
+
175
+ def any_ran?
176
+ all_ran?
177
+ @remaining.size < @expecting.size
178
+ end
179
+
180
+ end
181
+
182
+ # Tests that all the tasks ran, in the order specified. Can also be used to test that some
183
+ # tasks and not others ran.
184
+ #
185
+ # Takes a list of arguments. Each argument can be a task name, matching only if that task ran.
186
+ # Each argument can be an array of task names, matching only if all these tasks ran in that order.
187
+ # So run_tasks('foo', 'bar') expects foo and bar to run in any order, but run_task(['foo', 'bar'])
188
+ # expects foo to run before bar.
189
+ #
190
+ # You can call but_not on the matchers to specify that certain tasks must not execute.
191
+ #
192
+ # For example:
193
+ # # Either task
194
+ # lambda { task('compile').invoke }.should run_tasks('compile', 'resources')
195
+ # # In that order
196
+ # lambda { task('build').invoke }.should run_tasks(['compile', 'test'])
197
+ # # With exclusion
198
+ # lambda { task('build').invoke }.should run_tasks('compile').but_not('install')
199
+ def run_tasks(*tasks)
200
+ InvokeMatcher.new *tasks
201
+ end
202
+
203
+ # Tests that a task ran. Similar to run_tasks, but accepts a single task name.
204
+ #
205
+ # For example:
206
+ # lambda { task('build').invoke }.should run_task('test')
207
+ def run_task(task)
208
+ InvokeMatcher.new [task]
209
+ end
210
+
211
+ class UriPathMatcher
212
+ def initialize(re)
213
+ @expression = re
214
+ end
215
+
216
+ def matches?(uri)
217
+ @uri = uri
218
+ uri.path =~ @expression
219
+ end
220
+
221
+ def description
222
+ "URI with path matching #{@expression}"
223
+ end
224
+ end
225
+
226
+ # Matches a parsed URI's path against the given regular expression
227
+ def uri(re)
228
+ UriPathMatcher.new(re)
229
+ end
230
+
231
+
232
+ class AbsolutePathMatcher
233
+ def initialize(path)
234
+ @expected = File.expand_path(path.to_s)
235
+ end
236
+
237
+ def matches?(path)
238
+ @provided = File.expand_path(path.to_s)
239
+ @provided == @expected
240
+ end
241
+
242
+ def failure_message
243
+ "Expected path #{@expected}, but found path #{@provided}"
244
+ end
245
+
246
+ def negative_failure_message
247
+ "Expected a path other than #{@expected}"
248
+ end
249
+ end
250
+
251
+ def point_to_path(path)
252
+ AbsolutePathMatcher.new(path)
253
+ end
254
+
255
+
256
+ def suppress_stdout
257
+ stdout = $stdout
258
+ $stdout = StringIO.new
259
+ begin
260
+ yield
261
+ ensure
262
+ $stdout = stdout
263
+ end
264
+ end
265
+
266
+ def dryrun
267
+ Buildr.application.options.dryrun = true
268
+ begin
269
+ suppress_stdout { yield }
270
+ ensure
271
+ Buildr.application.options.dryrun = false
272
+ end
273
+ end
274
+
275
+ # We run tests with tracing off. Then things break. And we need to figure out what went wrong.
276
+ # So just use trace() as you would use verbose() to find and squash the bug.
277
+ def trace(value = nil)
278
+ old_value = Buildr.application.options.trace
279
+ Buildr.application.options.trace = value unless value.nil?
280
+ if block_given?
281
+ begin
282
+ yield
283
+ ensure
284
+ Buildr.application.options.trace = old_value
285
+ end
286
+ end
287
+ Buildr.application.options.trace
288
+ end
289
+
290
+ # Change the Buildr original directory, faking invocation from a different directory.
291
+ def in_original_dir(dir)
292
+ begin
293
+ original_dir = Buildr.application.original_dir
294
+ Buildr.application.instance_eval { @original_dir = File.expand_path(dir) }
295
+ yield
296
+ ensure
297
+ Buildr.application.instance_eval { @original_dir = original_dir }
298
+ end
299
+ end
300
+
301
+
302
+ # Buildr's define method creates a project definition but does not evaluate it
303
+ # (that happens once the buildfile is loaded), and we include Buildr's define in
304
+ # the test context so we can use it without prefixing with Buildr. This just patches
305
+ # define to evaluate the project definition before returning it.
306
+ def define(name, properties = nil, &block) #:yields:project
307
+ Project.define(name, properties, &block).tap { |project| project.invoke }
308
+ end
309
+
310
+ end
311
+
312
+
313
+ # Allow using matchers within the project definition.
314
+ class Buildr::Project
315
+ include ::Spec::Matchers, SpecHelpers
316
+ end
317
+
318
+
319
+ Spec::Runner.configure do |config|
320
+ # Make all Buildr methods accessible from test cases, and add various helper methods.
321
+ config.include Buildr, SpecHelpers
322
+
323
+ # Sanbdox Buildr for each test.
324
+ config.include Sandbox
325
+ end
326
+
327
+ end
@@ -0,0 +1,123 @@
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
+ describe Buildr::VersionRequirement, '.create' do
20
+ def create(str)
21
+ Buildr::VersionRequirement.create(str)
22
+ end
23
+
24
+ it 'should complain on invalid input' do
25
+ lambda { create }.should raise_error(Exception)
26
+ lambda { create('%') }.should raise_error(Exception, /invalid character/)
27
+ lambda { create('1#{0}') }.should raise_error(Exception, /invalid character/)
28
+ lambda { create('1.0rc`exit`') }.should raise_error(Exception, /invalid character/)
29
+ lambda { create(1.0) }.should raise_error(Exception)
30
+ lambda { create('1.0') }.should_not raise_error(Exception)
31
+ lambda { create('1.0rc3') }.should_not raise_error(Exception)
32
+ end
33
+
34
+ it 'should allow versions using hyphen' do
35
+ lambda { create('1.0-rc3') }.should_not raise_error(Exception)
36
+ end
37
+
38
+ it 'should create a single version requirement' do
39
+ create('1.0').should_not be_composed
40
+ end
41
+
42
+ it 'should create a composed version requirement' do
43
+ create('1.0 | 2.1').should be_composed
44
+ end
45
+ end
46
+
47
+ describe Buildr::VersionRequirement, '#satisfied_by?' do
48
+ def should_satisfy(str, valids = [], invalids = [])
49
+ req = Buildr::VersionRequirement.create(str)
50
+ valids.each { |v| req.should be_satisfied_by(v) }
51
+ invalids.each { |v| req.should_not be_satisfied_by(v) }
52
+ end
53
+
54
+ it 'should accept Gem version operators' do
55
+ should_satisfy '1.0', %w(1 1.0), %w(1.1 0.1)
56
+ should_satisfy '=1.0', %w(1 1.0), %w(1.1 0.1)
57
+ should_satisfy '= 1.0', %w(1 1.0), %w(1.1 0.1)
58
+ should_satisfy '!= 1.0', %w(0.9 1.1 2), %w(1 1.0 1.0.0)
59
+
60
+ should_satisfy '>1.0', %w(1.0.1), %w(1 1.0 0.1)
61
+ should_satisfy '>=1.0', %w(1.0.1 1 1.0), %w(0.9)
62
+
63
+ should_satisfy '<1.0', %w(0.9 0.9.9), %w(1 1.0 1.1 2)
64
+ should_satisfy '<=1.0', %w(0.9 0.9.9 1 1.0), %w(1.1 2)
65
+
66
+ should_satisfy '~> 1.2.3', %w(1.2.3 1.2.3.4 1.2.4), %w(1.2.1 0.9 1.4 2)
67
+ end
68
+
69
+ it 'should accept logic not operator' do
70
+ should_satisfy 'not 0.5', %w(0 1), %w(0.5)
71
+ should_satisfy '! 0.5', %w(0 1), %w(0.5)
72
+ should_satisfy '!= 0.5', %w(0 1), %w(0.5)
73
+ should_satisfy '!<= 0.5', %w(0.5.1 2), %w(0.5)
74
+ end
75
+
76
+ it 'should accept logic or operator' do
77
+ should_satisfy '0.5 or 2.0', %w(0.5 2.0), %w(1.0 0.5.1 2.0.9)
78
+ should_satisfy '0.5 | 2.0', %w(0.5 2.0), %w(1.0 0.5.1 2.0.9)
79
+ end
80
+
81
+ it 'should accept logic and operator' do
82
+ should_satisfy '>1.5 and <2.0', %w(1.6 1.9), %w(1.5 2 2.0)
83
+ should_satisfy '>1.5 & <2.0', %w(1.6 1.9), %w(1.5 2 2.0)
84
+ end
85
+
86
+ it 'should assume logic and if missing operator between expressions' do
87
+ should_satisfy '>1.5 <2.0', %w(1.6 1.9), %w(1.5 2 2.0)
88
+ end
89
+
90
+ it 'should allow combining logic operators' do
91
+ should_satisfy '>1.0 | <2.0 | =3.0', %w(1.5 3.0 1 2 4)
92
+ should_satisfy '>1.0 & <2.0 | =3.0', %w(1.3 3.0), %w(1 2)
93
+ should_satisfy '=1.0 | <2.0 & =0.5', %w(0.5 1.0), %w(1.1 0.1 2)
94
+ should_satisfy '~>1.1 | ~>1.3 | ~>1.5 | 2.0', %w(2 1.5.6 1.1.2 1.1.3), %w(1.0.9 0.5 2.2.1)
95
+ should_satisfy 'not(2) | 1', %w(1 3), %w(2)
96
+ end
97
+
98
+ it 'should allow using parens to group logic expressions' do
99
+ should_satisfy '(1.0)', %w(1 1.0), %w(0.9 1.1)
100
+ should_satisfy '!( !(1.0) )', %w(1 1.0), %w(0.9 1.1)
101
+ should_satisfy '1 | !(2 | 3)', %w(1), %w(2 3)
102
+ should_satisfy '!(2 | 3) | 1', %w(1), %w(2 3)
103
+ end
104
+ end
105
+
106
+ describe Buildr::VersionRequirement, '#default' do
107
+ it 'should return nil if missing default requirement' do
108
+ Buildr::VersionRequirement.create('>1').default.should be_nil
109
+ Buildr::VersionRequirement.create('<1').default.should be_nil
110
+ Buildr::VersionRequirement.create('!1').default.should be_nil
111
+ Buildr::VersionRequirement.create('!<=1').default.should be_nil
112
+ end
113
+
114
+ it 'should return the last version with a = requirement' do
115
+ Buildr::VersionRequirement.create('1').default.should == '1'
116
+ Buildr::VersionRequirement.create('=1').default.should == '1'
117
+ Buildr::VersionRequirement.create('<=1').default.should == '1'
118
+ Buildr::VersionRequirement.create('>=1').default.should == '1'
119
+ Buildr::VersionRequirement.create('1 | 2 | 3').default.should == '3'
120
+ Buildr::VersionRequirement.create('1 2 | 3').default.should == '3'
121
+ Buildr::VersionRequirement.create('1 & 2 | 3').default.should == '3'
122
+ end
123
+ end