doubleshot 0.1.0-java → 0.2.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/Doubleshot +21 -10
- data/README.textile +13 -5
- data/bin/doubleshot +9 -1
- data/ext/java/Aether.java +199 -0
- data/ext/java/ManualWagonProvider.java +24 -0
- data/ext/java/SimpleRepositoryListener.java +77 -0
- data/lib/doubleshot.rb +155 -9
- data/lib/doubleshot/cli.rb +2 -1
- data/lib/doubleshot/cli/options.rb +3 -1
- data/lib/doubleshot/commands/build.rb +47 -9
- data/lib/doubleshot/commands/gem.rb +30 -9
- data/lib/doubleshot/commands/init.rb +41 -10
- data/lib/doubleshot/commands/install.rb +4 -4
- data/lib/doubleshot/commands/jar.rb +60 -2
- data/lib/doubleshot/commands/pom.rb +29 -0
- data/lib/doubleshot/commands/test.rb +85 -32
- data/lib/doubleshot/compiler.rb +20 -17
- data/lib/doubleshot/compiler/classpath.rb +46 -0
- data/lib/doubleshot/configuration.rb +158 -8
- data/lib/doubleshot/dependencies/dependency.rb +16 -15
- data/lib/doubleshot/dependencies/dependency_list.rb +20 -5
- data/lib/doubleshot/dependencies/gem_dependency.rb +35 -0
- data/lib/doubleshot/dependencies/gem_dependency_list.rb +1 -1
- data/lib/doubleshot/dependencies/jar_dependency.rb +64 -1
- data/lib/doubleshot/dependencies/jar_dependency_list.rb +1 -1
- data/lib/doubleshot/jar.rb +13 -2
- data/lib/doubleshot/lockfile.rb +108 -0
- data/lib/doubleshot/pom.rb +42 -0
- data/lib/doubleshot/readonly_collection.rb +6 -2
- data/lib/doubleshot/resolver.rb +22 -0
- data/lib/doubleshot/resolver/jar_resolver.rb +36 -0
- data/lib/doubleshot/setup.rb +1 -47
- data/lib/ruby/blank.rb +3 -3
- data/lib/ruby/pathname.rb +8 -4
- data/lib/ruby/time.rb +1 -2
- data/target/doubleshot.jar +0 -0
- data/test/compiler/classpath_spec.rb +74 -0
- data/test/compiler_spec.rb +89 -10
- data/test/configuration/source_locations_spec.rb +2 -2
- data/test/configuration_spec.rb +115 -17
- data/test/dependencies/dependency_list_spec.rb +26 -4
- data/test/dependencies/dependency_spec.rb +19 -18
- data/test/dependencies/gem_dependency_list_spec.rb +0 -0
- data/test/dependencies/gem_dependency_spec.rb +54 -0
- data/test/dependencies/jar_dependency_list_spec.rb +0 -0
- data/test/dependencies/jar_dependency_spec.rb +62 -1
- data/test/dependencies_spec.rb +4 -4
- data/test/doubleshot_spec.rb +34 -2
- data/test/helper.rb +36 -1
- data/test/lockfile_spec.rb +236 -0
- data/test/pom_spec.rb +66 -0
- data/test/readonly_collection_spec.rb +10 -3
- data/test/resolver/jar_resolver_spec.rb +34 -0
- data/test/resolver_spec.rb +25 -0
- metadata +28 -28
- data/ext/java/Empty.java +0 -0
@@ -13,6 +13,28 @@ describe Doubleshot::Dependencies::DependencyList do
|
|
13
13
|
@list.must_be_kind_of Enumerable
|
14
14
|
end
|
15
15
|
|
16
|
+
describe "+" do
|
17
|
+
it "must allow you to concatenate two collections" do
|
18
|
+
one = Doubleshot::Dependencies::DependencyList.new
|
19
|
+
two = Doubleshot::Dependencies::DependencyList.new
|
20
|
+
|
21
|
+
listen = one.fetch "listen"
|
22
|
+
minitest = two.fetch "minitest"
|
23
|
+
|
24
|
+
(one + two).entries.must_equal [ listen, minitest ]
|
25
|
+
end
|
26
|
+
|
27
|
+
it "must raise an ArgumentError if the lists are not the same type" do
|
28
|
+
one = Doubleshot::Dependencies::DependencyList.new
|
29
|
+
two = Doubleshot::Dependencies::GemDependencyList.new
|
30
|
+
|
31
|
+
listen = one.fetch "listen"
|
32
|
+
minitest = two.fetch "minitest"
|
33
|
+
|
34
|
+
-> { one + two }.must_raise ArgumentError
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
16
38
|
describe "add" do
|
17
39
|
it "must only accept Dependency instances" do
|
18
40
|
assert_raises(ArgumentError) do
|
@@ -30,18 +52,18 @@ describe Doubleshot::Dependencies::DependencyList do
|
|
30
52
|
@list.add @dependency
|
31
53
|
@list.size.must_equal 1
|
32
54
|
end
|
33
|
-
|
55
|
+
|
34
56
|
it "must always return self for chainability" do
|
35
57
|
@list.add(@dependency).must_equal @list
|
36
58
|
end
|
37
59
|
end
|
38
|
-
|
60
|
+
|
39
61
|
describe "fetch" do
|
40
62
|
it "must find matching dependencies by name" do
|
41
63
|
@list.add @dependency
|
42
64
|
@list.fetch("listen").must_equal @dependency
|
43
65
|
end
|
44
|
-
|
66
|
+
|
45
67
|
it "must always return a dependency" do
|
46
68
|
@list.fetch("example").must_be_kind_of Doubleshot::Dependencies::Dependency
|
47
69
|
end
|
@@ -70,4 +92,4 @@ describe Doubleshot::Dependencies::DependencyList do
|
|
70
92
|
end
|
71
93
|
end
|
72
94
|
|
73
|
-
end
|
95
|
+
end
|
@@ -9,18 +9,6 @@ describe Doubleshot::Dependencies::Dependency do
|
|
9
9
|
@other = Doubleshot::Dependencies::Dependency.new "listen"
|
10
10
|
end
|
11
11
|
|
12
|
-
describe "add_requirement" do
|
13
|
-
it "must return a Gem::Requirement object" do
|
14
|
-
@dependency.add_requirement("1.0").must_be_kind_of Gem::Requirement
|
15
|
-
end
|
16
|
-
|
17
|
-
it "must not duplicate requirements" do
|
18
|
-
@dependency.add_requirement("2.0")
|
19
|
-
@dependency.add_requirement("2.0")
|
20
|
-
@dependency.requirements.size.must_equal 1
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
12
|
describe "Hash contract" do
|
25
13
|
|
26
14
|
# Dependency#name must be immutable since
|
@@ -38,12 +26,25 @@ describe Doubleshot::Dependencies::Dependency do
|
|
38
26
|
end
|
39
27
|
end
|
40
28
|
|
41
|
-
describe "
|
29
|
+
describe "lock" do
|
30
|
+
it "must lock to a specific version" do
|
31
|
+
@dependency.lock "0.5.3"
|
32
|
+
@dependency.must_be :locked?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "to_s" do
|
37
|
+
before do
|
38
|
+
@dependency.lock "0.5.3"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "must have a short-form" do
|
42
|
+
@dependency.to_s.must_equal "listen"
|
43
|
+
end
|
42
44
|
|
43
|
-
it "must
|
44
|
-
@dependency.
|
45
|
-
@other.add_requirement ">= 0.1.0"
|
46
|
-
@dependency.wont_be :==, @other
|
45
|
+
it "must have a long-form" do
|
46
|
+
@dependency.to_s(true).must_equal "listen (0.5.3)"
|
47
47
|
end
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
|
+
end
|
File without changes
|
@@ -4,4 +4,58 @@ require_relative "../helper"
|
|
4
4
|
|
5
5
|
describe Doubleshot::Dependencies::GemDependency do
|
6
6
|
|
7
|
+
before do
|
8
|
+
@dependency = Doubleshot::Dependencies::GemDependency.new "listen"
|
9
|
+
@other = Doubleshot::Dependencies::GemDependency.new "listen"
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "add_requirement" do
|
13
|
+
it "must return a Gem::Requirement object" do
|
14
|
+
@dependency.add_requirement("1.0").must_be_kind_of Gem::Requirement
|
15
|
+
end
|
16
|
+
|
17
|
+
it "must not duplicate requirements" do
|
18
|
+
@dependency.add_requirement("2.0")
|
19
|
+
@dependency.add_requirement("2.0")
|
20
|
+
@dependency.requirements.size.must_equal 1
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "equality" do
|
25
|
+
it "must override the equality operator to consider requirements" do
|
26
|
+
@dependency.must_be :==, @other
|
27
|
+
@other.add_requirement ">= 0.1.0"
|
28
|
+
@dependency.wont_be :==, @other
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "to_s" do
|
33
|
+
before do
|
34
|
+
@dependency.add_requirement ">= 0.5"
|
35
|
+
@dependency.add_requirement "= 0.5.3"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "must have a short-form" do
|
39
|
+
@dependency.to_s.must_equal "listen"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "must have a long-form that includes requirements" do
|
43
|
+
@dependency.to_s(true).must_equal "listen (= 0.5.3, >= 0.5)"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "gemspec" do
|
48
|
+
it "must return a Gem::Specification" do
|
49
|
+
skip
|
50
|
+
@dependency.gemspec = Gem::Specification.new
|
51
|
+
@dependency.gemspec.must_be_kind_of Gem::Specification
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "dependencies" do
|
56
|
+
it "must return a Doubleshot::Dependencies::DependencyList" do
|
57
|
+
skip
|
58
|
+
@dependency.dependencies.must_be_kind_of Doubleshot::Dependencies::DependencyList
|
59
|
+
end
|
60
|
+
end
|
7
61
|
end
|
File without changes
|
@@ -3,5 +3,66 @@
|
|
3
3
|
require_relative "../helper"
|
4
4
|
|
5
5
|
describe Doubleshot::Dependencies::JarDependency do
|
6
|
+
# ch.qos.logback:logback-core:1.0.6
|
7
|
+
# ch.qos.logback:logback-core:jar:1.0.6
|
8
|
+
# ch.qos.logback:logback-core:jar:someclassifier:1.0.6
|
9
|
+
# <#JarDependency type: [pom|jar|maven-plugin|ejb|war|ear|rar|par|bundle] artifact: "logback-core" group: "ch.qos.logback" version: "1.0.6" classifier: "someclassifier">
|
6
10
|
|
7
|
-
|
11
|
+
it "must only accept Maven coordinate syntax" do
|
12
|
+
assert_raises(ArgumentError) do
|
13
|
+
Doubleshot::Dependencies::JarDependency.new "ch.qos.logback:logback-core:jar"
|
14
|
+
end
|
15
|
+
|
16
|
+
assert_raises(ArgumentError) do
|
17
|
+
Doubleshot::Dependencies::JarDependency.new "ch.qos.logback"
|
18
|
+
end
|
19
|
+
|
20
|
+
assert_raises(ArgumentError) do
|
21
|
+
Doubleshot::Dependencies::JarDependency.new "ch.qos.logback:logback-core:jar:"
|
22
|
+
end
|
23
|
+
|
24
|
+
assert_raises(ArgumentError) do
|
25
|
+
Doubleshot::Dependencies::JarDependency.new "ch.qos.logback:logback-core::1.0.6"
|
26
|
+
end
|
27
|
+
|
28
|
+
assert_raises(ArgumentError) do
|
29
|
+
Doubleshot::Dependencies::JarDependency.new "ch.qos.logback::jar:1.0.6"
|
30
|
+
end
|
31
|
+
|
32
|
+
assert_raises(ArgumentError) do
|
33
|
+
Doubleshot::Dependencies::JarDependency.new ":logback-core:jar:1.0.6"
|
34
|
+
end
|
35
|
+
|
36
|
+
assert_raises(ArgumentError) do
|
37
|
+
Doubleshot::Dependencies::JarDependency.new ":::"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns a Maven coordinate as the name" do
|
42
|
+
Doubleshot::Dependencies::JarDependency.new("ch.qos.logback:logback-core:jar:1.0.6")
|
43
|
+
.name.must_equal "ch.qos.logback:logback-core:jar:1.0.6"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "correctly parses the Maven coordinate" do
|
47
|
+
dependency = Doubleshot::Dependencies::JarDependency.new "ch.qos.logback:logback-core:jar:1.0.6"
|
48
|
+
dependency.packaging.must_equal "jar"
|
49
|
+
dependency.artifact.must_equal "logback-core"
|
50
|
+
dependency.group.must_equal "ch.qos.logback"
|
51
|
+
dependency.version.must_equal "1.0.6"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "returns a Maven coordinate as the long form of to_s" do
|
55
|
+
Doubleshot::Dependencies::JarDependency.new("ch.qos.logback:logback-core:jar:1.0.6")
|
56
|
+
.to_s(true).must_equal "ch.qos.logback:logback-core:jar:1.0.6"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "returns a 4-part Maven coordinate as the name if you used a 3-part Maven coordinate to create the dependency" do
|
60
|
+
Doubleshot::Dependencies::JarDependency.new("ch.qos.logback:logback-core:1.0.6")
|
61
|
+
.name.must_equal "ch.qos.logback:logback-core:jar:1.0.6"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns a 4-part Maven coordinate as the long form of to_s if you used a 3-part Maven coordinate to create the dependency" do
|
65
|
+
Doubleshot::Dependencies::JarDependency.new("ch.qos.logback:logback-core:1.0.6")
|
66
|
+
.to_s(true).must_equal "ch.qos.logback:logback-core:jar:1.0.6"
|
67
|
+
end
|
68
|
+
end
|
data/test/dependencies_spec.rb
CHANGED
@@ -10,7 +10,7 @@ describe Doubleshot::Dependencies do
|
|
10
10
|
|
11
11
|
describe "gems" do
|
12
12
|
it "must be a DependencyList" do
|
13
|
-
@dependencies.gems.must_be_kind_of Doubleshot::Dependencies::DependencyList
|
13
|
+
@dependencies.gems.must_be_kind_of Doubleshot::Dependencies::DependencyList
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -27,16 +27,16 @@ describe Doubleshot::Dependencies do
|
|
27
27
|
# NOTE: #fetch will add the dependency if it does
|
28
28
|
# not yet exist in the List.
|
29
29
|
@dependencies.gems.fetch "listen"
|
30
|
-
@dependencies.jars.fetch "
|
30
|
+
@dependencies.jars.fetch "commons-cli:commons-cli:jar:1.2"
|
31
31
|
end
|
32
32
|
|
33
33
|
it "must equal if their DependencyLists are equal" do
|
34
34
|
@dependencies.wont_equal @other
|
35
35
|
|
36
36
|
@other.gems.fetch "listen"
|
37
|
-
@other.jars.fetch "
|
37
|
+
@other.jars.fetch "commons-cli:commons-cli:jar:1.2"
|
38
38
|
|
39
39
|
@dependencies.must_equal @other
|
40
40
|
end
|
41
41
|
end
|
42
|
-
end
|
42
|
+
end
|
data/test/doubleshot_spec.rb
CHANGED
@@ -4,6 +4,32 @@ require_relative "helper.rb"
|
|
4
4
|
|
5
5
|
describe Doubleshot do
|
6
6
|
|
7
|
+
describe "classpath_cache" do
|
8
|
+
it "must be a Pathname" do
|
9
|
+
Doubleshot.new.classpath_cache.must_be_kind_of Pathname
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "classpath" do
|
14
|
+
before do
|
15
|
+
@doubleshot = Doubleshot.new do |config|
|
16
|
+
config.jar "ch.qos.logback:logback-core:1.0.6"
|
17
|
+
end
|
18
|
+
Helper::tmp do |tmp|
|
19
|
+
@doubleshot.path = tmp + "Doubleshot.test"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "must be empty on instantiation" do
|
24
|
+
@doubleshot.classpath.must_be_empty
|
25
|
+
end
|
26
|
+
|
27
|
+
it "won't be empty after setup (if you have JAR dependencies)" do
|
28
|
+
@doubleshot.setup!
|
29
|
+
@doubleshot.classpath.wont_be_empty
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
7
33
|
describe "configuration" do
|
8
34
|
it "must pass a Configuration object to the block" do
|
9
35
|
called = false
|
@@ -12,7 +38,7 @@ describe Doubleshot do
|
|
12
38
|
config.must_be_kind_of Doubleshot::Configuration
|
13
39
|
end
|
14
40
|
assert called, "block not called"
|
15
|
-
end
|
41
|
+
end
|
16
42
|
end
|
17
43
|
|
18
44
|
it "must generate a valid gemspec" do
|
@@ -44,8 +70,14 @@ describe Doubleshot do
|
|
44
70
|
config.source.ruby.to_s.must_equal "lib"
|
45
71
|
config.target.to_s.must_equal "target"
|
46
72
|
end
|
73
|
+
|
74
|
+
describe "lockfile" do
|
75
|
+
it "must return a Lockfile instance" do
|
76
|
+
Doubleshot::current.lockfile.must_be_kind_of Doubleshot::Lockfile
|
77
|
+
end
|
78
|
+
end
|
47
79
|
end
|
48
80
|
|
49
81
|
|
50
82
|
|
51
|
-
end
|
83
|
+
end
|
data/test/helper.rb
CHANGED
@@ -1,9 +1,44 @@
|
|
1
|
-
require_relative "../lib/doubleshot"
|
1
|
+
require_relative "../lib/doubleshot/setup"
|
2
|
+
|
3
|
+
require "doubleshot/resolver"
|
2
4
|
|
3
5
|
require "minitest/autorun"
|
4
6
|
require "minitest/pride"
|
5
7
|
require "minitest/wscolor"
|
6
8
|
|
9
|
+
module MiniTest
|
10
|
+
module Assertions
|
11
|
+
def assert_predicate o1, op, msg = nil
|
12
|
+
msg = message(msg) { "Expected #{mu_pp(o1)} to be #{op}" }
|
13
|
+
if !o1.respond_to?(op) && o1.respond_to?("#{op}?")
|
14
|
+
assert o1.__send__("#{op}?"), msg
|
15
|
+
else
|
16
|
+
assert o1.__send__(op), msg
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def refute_predicate o1, op, msg = nil
|
21
|
+
msg = message(msg) { "Expected #{mu_pp(o1)} to not be #{op}" }
|
22
|
+
if !o1.respond_to?(op) && o1.respond_to?("#{op}?")
|
23
|
+
refute o1.__send__("#{op}?"), msg
|
24
|
+
else
|
25
|
+
refute o1.__send__(op), msg
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module Expectations
|
31
|
+
# This is for aesthetics, so instead of:
|
32
|
+
# something.must_be :validate
|
33
|
+
# Or:
|
34
|
+
# something.validate.must_equal true
|
35
|
+
# Which are both terribly ugly, we can:
|
36
|
+
# something.must :validate
|
37
|
+
infect_an_assertion :assert_operator, :must, :reverse
|
38
|
+
infect_an_assertion :refute_operator, :wont, :reverse
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
7
42
|
module Helper
|
8
43
|
def self.tmp(path = "tmp")
|
9
44
|
dir = Pathname(path.to_s)
|
@@ -0,0 +1,236 @@
|
|
1
|
+
#!/usr/bin/env jruby
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
|
5
|
+
require_relative "helper"
|
6
|
+
|
7
|
+
describe Doubleshot::Lockfile do
|
8
|
+
|
9
|
+
def lockfile(name = "test.lock")
|
10
|
+
Helper::tmp do |tmp|
|
11
|
+
(tmp + name).open("w+") do |file|
|
12
|
+
file << {}.to_yaml
|
13
|
+
end
|
14
|
+
yield Doubleshot::Lockfile.new(tmp + name)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
before do
|
19
|
+
@jar = Doubleshot::Dependencies::JarDependency.new("ch.qos.logback:logback-core:jar:1.0.6")
|
20
|
+
@gem = Doubleshot::Dependencies::GemDependency.new("listen")
|
21
|
+
@gem.lock("0.5.3")
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "Pathname delegations" do
|
25
|
+
it "#exist?" do
|
26
|
+
lockfile do |lockfile|
|
27
|
+
lockfile.must :exist
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "#mtime" do
|
32
|
+
lockfile do |lockfile|
|
33
|
+
lockfile.mtime.must_be_kind_of Time
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "#delete" do
|
38
|
+
lockfile do |lockfile|
|
39
|
+
lockfile.must :exist
|
40
|
+
lockfile.delete
|
41
|
+
lockfile.wont :exist
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "flush!" do
|
47
|
+
it "must write the JarDependencyList to the lockfile on disk such that an equal JarDependencyList will be loaded from that lockfile" do
|
48
|
+
lockfile do |lockfile|
|
49
|
+
lockfile.add Doubleshot::Dependencies::JarDependency.new("ch.qos.logback:logback-core:jar:1.0.6")
|
50
|
+
lockfile.flush!
|
51
|
+
Doubleshot::Lockfile.new(lockfile.path).jars.must_equal lockfile.jars
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "path" do
|
57
|
+
it "must default to 'Doubleshot.lock'" do
|
58
|
+
Doubleshot::Lockfile.new.path.must_equal Pathname("Doubleshot.lock")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "must let you specify a path" do
|
62
|
+
Doubleshot::Lockfile.new("myproject.lock").path.must_equal Pathname("myproject.lock")
|
63
|
+
end
|
64
|
+
|
65
|
+
it "must not create the lockfile on disk implicitly" do
|
66
|
+
Doubleshot::Lockfile.new "myproject.lock"
|
67
|
+
Pathname("myproject.lock").exist?.wont_equal true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "add" do
|
72
|
+
it "must not be empty after adding a dependency" do
|
73
|
+
lockfile do |lockfile|
|
74
|
+
lockfile.add @jar
|
75
|
+
lockfile.wont_be_empty
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
it "must return self" do
|
80
|
+
lockfile do |lockfile|
|
81
|
+
lockfile.add(@jar).must_be_same_as lockfile
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
it "must raise an ArgumentError if passing an abstract Dependency instance" do
|
86
|
+
assert_raises(ArgumentError) do
|
87
|
+
lockfile do |lockfile|
|
88
|
+
lockfile.add Doubleshot::Dependencies::Dependency.new "listen"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it "must raise if a non-dependency is passed" do
|
94
|
+
assert_raises(ArgumentError) do
|
95
|
+
lockfile do |lockfile|
|
96
|
+
lockfile.add "listen"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
it "must not add a dependency twice" do
|
102
|
+
lockfile do |lockfile|
|
103
|
+
lockfile.add @jar
|
104
|
+
lockfile.add Doubleshot::Dependencies::JarDependency.new("ch.qos.logback:logback-core:jar:1.0.6")
|
105
|
+
lockfile.jars.size.must_equal 1
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
it "must reject unlocked dependencies" do
|
110
|
+
assert_raises(Doubleshot::Lockfile::UnlockedDependencyError) do
|
111
|
+
lockfile do |lockfile|
|
112
|
+
lockfile.add Doubleshot::Dependencies::GemDependency.new("listen")
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
it "must raise an error if it doesn't know how to handle the dependency you've passed" do
|
118
|
+
assert_raises(Doubleshot::Lockfile::UnknownDependencyTypeError) do
|
119
|
+
dependency = Class.new(Doubleshot::Dependencies::Dependency) do
|
120
|
+
def locked?
|
121
|
+
true
|
122
|
+
end
|
123
|
+
end.new("some-raa-tar")
|
124
|
+
|
125
|
+
lockfile do |lockfile|
|
126
|
+
lockfile.add(dependency)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "jars" do
|
133
|
+
it "must return the list of JAR dependencies" do
|
134
|
+
lockfile do |lockfile|
|
135
|
+
lockfile.add @jar
|
136
|
+
lockfile.jars.size.must_equal 1
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
it "must be readonly" do
|
141
|
+
lockfile do |lockfile|
|
142
|
+
lockfile.jars.must_be_kind_of Doubleshot::ReadonlyCollection
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe "gems" do
|
148
|
+
it "must return the list of Gem dependencies" do
|
149
|
+
lockfile do |lockfile|
|
150
|
+
lockfile.add @gem
|
151
|
+
lockfile.gems.size.must_equal 1
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
it "must be readonly" do
|
156
|
+
lockfile do |lockfile|
|
157
|
+
lockfile.gems.must_be_kind_of Doubleshot::ReadonlyCollection
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe "jar format" do
|
163
|
+
before do
|
164
|
+
@lockfile_contents = <<-EOS.margin
|
165
|
+
---
|
166
|
+
GEMS: []
|
167
|
+
JARS:
|
168
|
+
- com.pyx4j:maven-plugin-log4j:jar:1.0.1
|
169
|
+
- org.springframework:spring-core:jar:3.1.2.RELEASE
|
170
|
+
- org.hibernate:hibernate-core:jar:4.1.7.Final
|
171
|
+
EOS
|
172
|
+
end
|
173
|
+
|
174
|
+
it "must handle proper YAML format" do
|
175
|
+
lockfile "test_good.lock" do |lockfile|
|
176
|
+
lockfile.path.open("w+") do |file|
|
177
|
+
file << @lockfile_contents
|
178
|
+
end
|
179
|
+
lockfile.jars.size.must_equal 3
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
it "must raise a Psych::SyntaxError for invalid YAML" do
|
184
|
+
lockfile "test_bad.lock" do |lockfile|
|
185
|
+
lockfile.path.open("w+") do |file|
|
186
|
+
file << "<(^.^)> <(^.^<) (>^.^)>" << @lockfile_contents
|
187
|
+
end
|
188
|
+
-> { lockfile.jars }.must_raise Psych::SyntaxError
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
describe "gem format" do
|
194
|
+
before do
|
195
|
+
@lockfile_contents = <<-EOS.margin
|
196
|
+
---
|
197
|
+
GEMS:
|
198
|
+
backports (2.6.4): []
|
199
|
+
ffi (1.0.11): []
|
200
|
+
ffi (1.0.11-java): []
|
201
|
+
hitimes (1.1.1): []
|
202
|
+
hitimes (1.1.1-java): []
|
203
|
+
minitest (3.4.0): []
|
204
|
+
minitest-wscolor (0.0.3):
|
205
|
+
- minitest (>= 2.3.1)
|
206
|
+
multi_json (1.3.6): []
|
207
|
+
path (1.3.1): []
|
208
|
+
perfer (0.2.0):
|
209
|
+
- backports (~> 2.6.3)
|
210
|
+
- ffi (~> 1.0.11)
|
211
|
+
- hitimes (~> 1.1.1)
|
212
|
+
- path (~> 1.3.1)
|
213
|
+
JARS: []
|
214
|
+
EOS
|
215
|
+
end
|
216
|
+
|
217
|
+
it "must handle proper YAML format" do
|
218
|
+
skip
|
219
|
+
lockfile "test_good.lock" do |lockfile|
|
220
|
+
lockfile.path.open("w+") do |file|
|
221
|
+
file << @lockfile_contents
|
222
|
+
end
|
223
|
+
lockfile.gems.size.must_equal 10
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
it "must raise a Psych::SyntaxError for invalid YAML" do
|
228
|
+
lockfile "test_bad.lock" do |lockfile|
|
229
|
+
lockfile.path.open("w+") do |file|
|
230
|
+
file << "<(^.^)> <(^.^<) (>^.^)>" << @lockfile_contents
|
231
|
+
end
|
232
|
+
-> { lockfile.gems }.must_raise Psych::SyntaxError
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|