doubleshot 0.2.0-java → 0.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.
- data/Doubleshot +16 -6
- data/README-OLD.textile +216 -0
- data/README.textile +38 -182
- data/lib/doubleshot.rb +100 -39
- data/lib/doubleshot/commands/gem.rb +15 -12
- data/lib/doubleshot/commands/test.rb +38 -5
- data/lib/doubleshot/configuration.rb +2 -2
- data/lib/doubleshot/dependencies/dependency.rb +1 -1
- data/lib/doubleshot/dependencies/gem_dependency.rb +2 -10
- data/lib/doubleshot/dependencies/jar_dependency.rb +12 -2
- data/lib/doubleshot/lockfile.rb +9 -6
- data/lib/doubleshot/pom.rb +15 -2
- data/lib/doubleshot/resolver.rb +1 -0
- data/lib/doubleshot/resolver/gem_resolver.rb +45 -0
- data/lib/doubleshot/resolver/gem_resolver/artifact.rb +146 -0
- data/lib/doubleshot/resolver/gem_resolver/demand.rb +57 -0
- data/lib/doubleshot/resolver/gem_resolver/dependency.rb +57 -0
- data/lib/doubleshot/resolver/gem_resolver/errors.rb +37 -0
- data/lib/doubleshot/resolver/gem_resolver/gem_source.rb +58 -0
- data/lib/doubleshot/resolver/gem_resolver/graph.rb +200 -0
- data/lib/doubleshot/resolver/gem_resolver/solver.rb +279 -0
- data/lib/doubleshot/resolver/gem_resolver/solver/constraint_row.rb +29 -0
- data/lib/doubleshot/resolver/gem_resolver/solver/constraint_table.rb +35 -0
- data/lib/doubleshot/resolver/gem_resolver/solver/variable_row.rb +47 -0
- data/lib/doubleshot/resolver/gem_resolver/solver/variable_table.rb +59 -0
- data/lib/doubleshot/resolver/gem_resolver/source.rb +36 -0
- data/lib/doubleshot/resolver/jar_resolver.rb +1 -3
- data/lib/ruby/gem/requirement.rb +9 -0
- data/target/doubleshot.jar +0 -0
- data/test/compiler_spec.rb +31 -3
- data/test/configuration_spec.rb +11 -3
- data/test/dependencies/gem_dependency_spec.rb +3 -17
- data/test/dependencies/jar_dependency_spec.rb +20 -0
- data/test/helper.rb +3 -1
- data/test/helpers/stub_source.rb +120 -0
- data/test/lockfile_spec.rb +9 -17
- data/test/pom_spec.rb +31 -1
- data/test/resolver/gem_resolver/artifact_spec.rb +106 -0
- data/test/resolver/gem_resolver/demand_spec.rb +70 -0
- data/test/resolver/gem_resolver/dependency_spec.rb +33 -0
- data/test/resolver/gem_resolver/gem_source_spec.rb +28 -0
- data/test/resolver/gem_resolver/graph_spec.rb +239 -0
- data/test/resolver/gem_resolver/solver_spec.rb +449 -0
- data/test/resolver/gem_resolver/source_spec.rb +18 -0
- data/test/resolver/gem_resolver_spec.rb +102 -0
- metadata +35 -73
- data/lib/doubleshot/jar.rb +0 -62
@@ -0,0 +1,36 @@
|
|
1
|
+
require "uri"
|
2
|
+
|
3
|
+
class Doubleshot
|
4
|
+
class Resolver
|
5
|
+
class GemResolver
|
6
|
+
|
7
|
+
class Source
|
8
|
+
|
9
|
+
def self.map(*mime_types)
|
10
|
+
mime_types.each do |mime_type|
|
11
|
+
mappings[mime_type.to_s] = self
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.mappings
|
16
|
+
@@mappings ||= {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.new(uri)
|
20
|
+
uri = URI.parse(uri.to_s)
|
21
|
+
instance = mappings[uri.scheme].allocate
|
22
|
+
instance.send(:initialize, uri)
|
23
|
+
instance
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(uri)
|
27
|
+
@uri = uri
|
28
|
+
end
|
29
|
+
|
30
|
+
SUPPORTED_PLATFORMS = [ /\bjava\b/i, /^jruby$/i, /^ruby$/i ]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
require "doubleshot/resolver/gem_resolver/gem_source"
|
@@ -1,5 +1,3 @@
|
|
1
|
-
java_import "org.sam.doubleshot.Aether"
|
2
|
-
|
3
1
|
class Doubleshot
|
4
2
|
class Resolver
|
5
3
|
class JarResolver < Resolver
|
@@ -8,7 +6,7 @@ class Doubleshot
|
|
8
6
|
def initialize(*repositories)
|
9
7
|
super
|
10
8
|
# Change the second argument to "true" to get verbose output.
|
11
|
-
@aether = Aether.new(Pathname("~/.m2").expand_path.to_s, false, false)
|
9
|
+
@aether = org.sam.doubleshot.Aether.new(Pathname("~/.m2").expand_path.to_s, false, false)
|
12
10
|
@repositories.each do |repository|
|
13
11
|
@aether.add_repository repository.host, repository.to_s
|
14
12
|
end
|
data/lib/ruby/gem/requirement.rb
CHANGED
@@ -1,4 +1,13 @@
|
|
1
1
|
class Gem::Requirement
|
2
|
+
# TODO: refactor Doubleshot to only use satisfied_by?(Gem::Version) instead of satisfies?(String|Gem::Version)
|
3
|
+
def satisfies?(version)
|
4
|
+
unless version.is_a? Gem::Version
|
5
|
+
version = Gem::Version.new(version.to_s)
|
6
|
+
end
|
7
|
+
satisfied_by? version
|
8
|
+
end
|
9
|
+
alias :satisfies :satisfies?
|
10
|
+
|
2
11
|
def eql?(other)
|
3
12
|
self == other
|
4
13
|
end
|
data/target/doubleshot.jar
CHANGED
Binary file
|
data/test/compiler_spec.rb
CHANGED
@@ -4,12 +4,12 @@ require_relative "helper"
|
|
4
4
|
|
5
5
|
describe Doubleshot::Compiler do
|
6
6
|
|
7
|
-
def compile
|
7
|
+
def compile(source = "java", target = "target")
|
8
8
|
Helper::tmp do |tmp|
|
9
|
-
source = tmp +
|
9
|
+
source = tmp + source
|
10
10
|
source.mkdir
|
11
11
|
|
12
|
-
target = tmp +
|
12
|
+
target = tmp + target
|
13
13
|
target.mkdir
|
14
14
|
|
15
15
|
(source + "Cow.java").open("w+") do |cow|
|
@@ -43,6 +43,34 @@ describe Doubleshot::Compiler do
|
|
43
43
|
|
44
44
|
describe "#pending?" do
|
45
45
|
|
46
|
+
it "must be pending if the target doesn't exist" do
|
47
|
+
Helper::tmp do |tmp|
|
48
|
+
source = tmp + "java"
|
49
|
+
source.mkdir
|
50
|
+
|
51
|
+
target = tmp + "notarget"
|
52
|
+
# We're testing that target doesn't exist so:
|
53
|
+
# target.mkdir
|
54
|
+
|
55
|
+
(source + "Cow.java").open("w+") do |cow|
|
56
|
+
cow << <<-EOS.margin
|
57
|
+
package org.sam.doubleshot;
|
58
|
+
|
59
|
+
public class Cow {
|
60
|
+
public Cow() {}
|
61
|
+
|
62
|
+
public String moo() {
|
63
|
+
return "MOO!";
|
64
|
+
}
|
65
|
+
}
|
66
|
+
EOS
|
67
|
+
end
|
68
|
+
|
69
|
+
compiler = Doubleshot::Compiler.new(source, target)
|
70
|
+
compiler.must_be :pending
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
46
74
|
it "wont be pending after a build" do
|
47
75
|
compile do |compiler|
|
48
76
|
compiler.build!
|
data/test/configuration_spec.rb
CHANGED
@@ -62,12 +62,12 @@ describe Doubleshot::Configuration do
|
|
62
62
|
|
63
63
|
describe "repositories" do
|
64
64
|
it "must add Maven repositories" do
|
65
|
-
@config.mvn_repository "http://repository.jboss.com/maven2
|
66
|
-
@config.mvn_repositories.must_include "http://repository.jboss.com/maven2
|
65
|
+
@config.mvn_repository "http://repository.jboss.com/maven2"
|
66
|
+
@config.mvn_repositories.must_include "http://repository.jboss.com/maven2"
|
67
67
|
end
|
68
68
|
|
69
69
|
it "must return the passed value from mvn_repository" do
|
70
|
-
example = "http://repository.jboss.com/maven2
|
70
|
+
example = "http://repository.jboss.com/maven2"
|
71
71
|
@config.mvn_repository(example).must_be_same_as example
|
72
72
|
end
|
73
73
|
|
@@ -80,6 +80,14 @@ describe Doubleshot::Configuration do
|
|
80
80
|
example = "http://rubyforge.org"
|
81
81
|
@config.gem_repository(example).must_be_same_as example
|
82
82
|
end
|
83
|
+
|
84
|
+
it "must default to rubygems.org if no other gem repositories are specified" do
|
85
|
+
@config.gem_repositories.must_include "http://rubygems.org"
|
86
|
+
end
|
87
|
+
|
88
|
+
it "must default to central if no other maven repositories are specified" do
|
89
|
+
@config.mvn_repositories.must_include "http://repo1.maven.org/maven2"
|
90
|
+
end
|
83
91
|
end
|
84
92
|
|
85
93
|
describe "jar" do
|
@@ -39,23 +39,9 @@ describe Doubleshot::Dependencies::GemDependency do
|
|
39
39
|
@dependency.to_s.must_equal "listen"
|
40
40
|
end
|
41
41
|
|
42
|
-
it "must have a long-form that includes
|
43
|
-
@dependency.
|
44
|
-
|
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
|
42
|
+
it "must have a long-form that includes version if present" do
|
43
|
+
@dependency.lock "0.5.3"
|
44
|
+
@dependency.to_s(true).must_equal "listen:0.5.3"
|
59
45
|
end
|
60
46
|
end
|
61
47
|
end
|
@@ -65,4 +65,24 @@ describe Doubleshot::Dependencies::JarDependency do
|
|
65
65
|
Doubleshot::Dependencies::JarDependency.new("ch.qos.logback:logback-core:1.0.6")
|
66
66
|
.to_s(true).must_equal "ch.qos.logback:logback-core:jar:1.0.6"
|
67
67
|
end
|
68
|
+
|
69
|
+
describe "exclude" do
|
70
|
+
before do
|
71
|
+
@jar_dependency = Doubleshot::Dependencies::JarDependency.new "org.sonatype.aether:aether-connector-wagon:1.13.1"
|
72
|
+
end
|
73
|
+
|
74
|
+
it "allows you to exclude a groupId:artifactId for use in POM-file dependency exclusions" do
|
75
|
+
@jar_dependency.exclude("org.sonatype.sisu:sisu-guice")
|
76
|
+
@jar_dependency.exclusions.must_equal [ "org.sonatype.sisu:sisu-guice" ]
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should verify that your exclusion string contains one and only one colon" do
|
80
|
+
-> { @jar_dependency.exclude "missing-colon" }.must_raise(ArgumentError)
|
81
|
+
-> { @jar_dependency.exclude "too:many:colons" }.must_raise(ArgumentError)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should return self so you can chain exclusions" do
|
85
|
+
@jar_dependency.exclude("org.sonatype.sisu:sisu-guice").must_equal @jar_dependency
|
86
|
+
end
|
87
|
+
end
|
68
88
|
end
|
data/test/helper.rb
CHANGED
@@ -0,0 +1,120 @@
|
|
1
|
+
module Helper
|
2
|
+
class StubSource < Doubleshot::Resolver::GemResolver::Source
|
3
|
+
map :stub
|
4
|
+
|
5
|
+
def self.index(gems)
|
6
|
+
@@index = {}
|
7
|
+
gems.each_pair do |name, versions|
|
8
|
+
specs = @@index[name] ||= {}
|
9
|
+
versions.each_pair do |version, dependencies|
|
10
|
+
spec = specs[Gem::Version.new(version)] = Gem::Specification.new
|
11
|
+
spec.name = name
|
12
|
+
spec.version = version
|
13
|
+
dependencies.each_pair do |name, versions|
|
14
|
+
spec.add_runtime_dependency name, *versions
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def versions(name)
|
21
|
+
@@index[name.to_s].keys
|
22
|
+
end
|
23
|
+
|
24
|
+
def spec(name, version)
|
25
|
+
@@index[name.to_s][version]
|
26
|
+
end
|
27
|
+
|
28
|
+
index(
|
29
|
+
"rdoc" => {
|
30
|
+
"3.12" => { "json" => "~>1.4" },
|
31
|
+
"3.9.0" => {},
|
32
|
+
"3.8.3" => { "json" => "=1.7.2" }
|
33
|
+
},
|
34
|
+
"json" => {
|
35
|
+
"1.7.5" => { "erubis" => "~>2.6.6" },
|
36
|
+
"1.7.4" => {},
|
37
|
+
"1.7.3" => {},
|
38
|
+
"1.7.2" => { "erubis" => "2.6.5" }
|
39
|
+
},
|
40
|
+
"minitest-wscolor" => {
|
41
|
+
"0.0.3" => { "minitest" => ">=2.3.1" },
|
42
|
+
"0.0.2" => {}
|
43
|
+
},
|
44
|
+
"minitest" => {
|
45
|
+
"3.0.4" => {},
|
46
|
+
"3.0.3" => {},
|
47
|
+
"3.0.0" => {},
|
48
|
+
"2.3.1" => {},
|
49
|
+
"2.3.0" => {},
|
50
|
+
},
|
51
|
+
"erubis" => {
|
52
|
+
"2.7.0" => { "minitest" => ">=3.0.0" },
|
53
|
+
"2.6.6" => {},
|
54
|
+
"2.6.5" => {}
|
55
|
+
},
|
56
|
+
"rack" => {
|
57
|
+
"1.4.1" => {},
|
58
|
+
"1.4.0" => {},
|
59
|
+
"1.3.6" => {},
|
60
|
+
"1.2.5" => {},
|
61
|
+
"1.1.3" => {}
|
62
|
+
},
|
63
|
+
"harbor" => {
|
64
|
+
"0.16.12" => { "erubis" => ">=0", "rack" => "~>1.0.0", "json" => ">=0" },
|
65
|
+
"0.16.11" => { "erubis" => ">=0", "rack" => "~>1.0.0" },
|
66
|
+
"0.16.10" => { "erubis" => ">=0", "rack" => ">=0" }
|
67
|
+
},
|
68
|
+
"hello" => {
|
69
|
+
"4.0" => { "harbor" => "~>0.16.10", "json" => "~>1.7.0", "minitest-wscolor" => "=0.0.3" },
|
70
|
+
"3.9" => { "harbor" => ">=0", "json" => ">=0", "minitest-wscolor" => ">=0", "minitest" => "~>2.3" },
|
71
|
+
"3.8" => { "harbor" => ">=0", "erubis" => "~>2.6.5" },
|
72
|
+
"2.2" => { "harbor" => ">=0" }
|
73
|
+
},
|
74
|
+
"top-level" => {
|
75
|
+
"1.0" => { "mid-level-1" => ">=0", "mid-level-2" => ">=0" }
|
76
|
+
},
|
77
|
+
"mid-level-1" => {
|
78
|
+
"2.0" => { "bottom-level" => [ ">=1.0", "<=3.0" ] },
|
79
|
+
"1.0" => {}
|
80
|
+
},
|
81
|
+
"mid-level-2" => {
|
82
|
+
"2.0" => { "bottom-level" => ">=2.0" },
|
83
|
+
"1.0" => {}
|
84
|
+
},
|
85
|
+
"bottom-level" => {
|
86
|
+
"2.3" => {},
|
87
|
+
"2.0" => {},
|
88
|
+
"1.3" => {},
|
89
|
+
"1.0" => {},
|
90
|
+
"0.9" => {}
|
91
|
+
},
|
92
|
+
"get-the-old-one" => {
|
93
|
+
"1.0" => { "locked-mid-1" => ">=0", "locked-mid-2" => ">=0" },
|
94
|
+
"0.5" => {}
|
95
|
+
},
|
96
|
+
"locked-mid-1" => {
|
97
|
+
"2.0" => { "old-bottom" => "=2.0" },
|
98
|
+
"1.3" => { "old-bottom" => "=0.5" },
|
99
|
+
"1.0" => {}
|
100
|
+
},
|
101
|
+
"locked-mid-2" => {
|
102
|
+
"2.0" => { "old-bottom" => "=2.1" },
|
103
|
+
"1.4" => { "old-bottom" => "=0.5" },
|
104
|
+
"1.0" => {}
|
105
|
+
},
|
106
|
+
"old-bottom" => {
|
107
|
+
"2.1" => {},
|
108
|
+
"2.0" => {},
|
109
|
+
"1.0" => {},
|
110
|
+
"0.5" => {}
|
111
|
+
},
|
112
|
+
"oops" => {
|
113
|
+
"1.0" => { "oops-2" => "=2.0" }
|
114
|
+
},
|
115
|
+
"oops-2" => {
|
116
|
+
"1.0" => {}
|
117
|
+
}
|
118
|
+
)
|
119
|
+
end
|
120
|
+
end
|
data/test/lockfile_spec.rb
CHANGED
@@ -195,32 +195,24 @@ describe Doubleshot::Lockfile do
|
|
195
195
|
@lockfile_contents = <<-EOS.margin
|
196
196
|
---
|
197
197
|
GEMS:
|
198
|
-
backports
|
199
|
-
ffi
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
-
|
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)
|
198
|
+
- backports:2.6.4
|
199
|
+
- ffi:1.0.11
|
200
|
+
- hitimes:1.1.1
|
201
|
+
- minitest:3.4.0
|
202
|
+
- minitest-wscolor:0.0.3
|
203
|
+
- multi_json:1.3.6
|
204
|
+
- path:1.3.1
|
205
|
+
- perfer:0.2.0
|
213
206
|
JARS: []
|
214
207
|
EOS
|
215
208
|
end
|
216
209
|
|
217
210
|
it "must handle proper YAML format" do
|
218
|
-
skip
|
219
211
|
lockfile "test_good.lock" do |lockfile|
|
220
212
|
lockfile.path.open("w+") do |file|
|
221
213
|
file << @lockfile_contents
|
222
214
|
end
|
223
|
-
lockfile.gems.size.must_equal
|
215
|
+
lockfile.gems.size.must_equal 8
|
224
216
|
end
|
225
217
|
end
|
226
218
|
|
data/test/pom_spec.rb
CHANGED
@@ -15,6 +15,8 @@ describe Doubleshot::Pom do
|
|
15
15
|
config.jar "org.jruby:jruby-complete:jar:1.7.0.RC1"
|
16
16
|
config.jar "org.sonatype.aether:aether-api:jar:1.13.1"
|
17
17
|
config.jar "org.sonatype.aether:aether-util:jar:1.13.1"
|
18
|
+
config.jar("org.sonatype.aether:aether-connector-wagon:1.13.1").exclude("org.sonatype.sisu:sisu-guice")
|
19
|
+
config.jar("testing:chaining-exclusions:jar:0.0.1").exclude("testing:exclusion-1").exclude("testing:exclusion-2")
|
18
20
|
|
19
21
|
config.gemspec do |spec|
|
20
22
|
spec.summary = "Build, Dependencies and Testing all in one!"
|
@@ -59,8 +61,36 @@ describe Doubleshot::Pom do
|
|
59
61
|
<type>jar</type>
|
60
62
|
<version>1.13.1</version>
|
61
63
|
</dependency>
|
64
|
+
<dependency>
|
65
|
+
<groupId>org.sonatype.aether</groupId>
|
66
|
+
<artifactId>aether-connector-wagon</artifactId>
|
67
|
+
<type>jar</type>
|
68
|
+
<version>1.13.1</version>
|
69
|
+
<exclusions>
|
70
|
+
<exclusion>
|
71
|
+
<groupId>org.sonatype.sisu</groupId>
|
72
|
+
<artifactId>sisu-guice</artifactId>
|
73
|
+
</exclusion>
|
74
|
+
</exclusions>
|
75
|
+
</dependency>
|
76
|
+
<dependency>
|
77
|
+
<groupId>testing</groupId>
|
78
|
+
<artifactId>chaining-exclusions</artifactId>
|
79
|
+
<type>jar</type>
|
80
|
+
<version>0.0.1</version>
|
81
|
+
<exclusions>
|
82
|
+
<exclusion>
|
83
|
+
<groupId>testing</groupId>
|
84
|
+
<artifactId>exclusion-1</artifactId>
|
85
|
+
</exclusion>
|
86
|
+
<exclusion>
|
87
|
+
<groupId>testing</groupId>
|
88
|
+
<artifactId>exclusion-2</artifactId>
|
89
|
+
</exclusion>
|
90
|
+
</exclusions>
|
91
|
+
</dependency>
|
62
92
|
</dependencies>
|
63
93
|
</project>
|
64
94
|
EOS
|
65
95
|
end
|
66
|
-
end
|
96
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
#!/usr/bin/env jruby
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
|
5
|
+
require_relative "../../helper"
|
6
|
+
|
7
|
+
describe Doubleshot::Resolver::GemResolver::Artifact do
|
8
|
+
|
9
|
+
before do
|
10
|
+
@graph = Doubleshot::Resolver::GemResolver::Graph.new
|
11
|
+
@artifact = Doubleshot::Resolver::GemResolver::Artifact.new(@graph, "listen", "1.0")
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "equality" do
|
15
|
+
it "must equal another artifact with the same name and version" do
|
16
|
+
artifact_1 = Doubleshot::Resolver::GemResolver::Artifact.new(@graph, "listen", "1.0")
|
17
|
+
artifact_2 = Doubleshot::Resolver::GemResolver::Artifact.new(@graph, "listen", "1.0")
|
18
|
+
artifact_1.must_equal artifact_2
|
19
|
+
end
|
20
|
+
|
21
|
+
it "must not equal another artifact with the same name but different version" do
|
22
|
+
artifact_1 = Doubleshot::Resolver::GemResolver::Artifact.new(@graph, "listen", "1.0")
|
23
|
+
artifact_2 = Doubleshot::Resolver::GemResolver::Artifact.new(@graph, "listen", "2.0")
|
24
|
+
artifact_1.wont_equal artifact_2
|
25
|
+
end
|
26
|
+
|
27
|
+
it "must not equal another artifact with the same version but different name" do
|
28
|
+
artifact_1 = Doubleshot::Resolver::GemResolver::Artifact.new(@graph, "listen", "1.0")
|
29
|
+
artifact_2 = Doubleshot::Resolver::GemResolver::Artifact.new(@graph, "not_listen", "1.0")
|
30
|
+
artifact_1.wont_equal artifact_2
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "sorting" do
|
35
|
+
it "must sort artifacts by their name, then version number" do
|
36
|
+
artifact_1 = Doubleshot::Resolver::GemResolver::Artifact.new(@graph, "listen", "1.0")
|
37
|
+
artifact_2 = Doubleshot::Resolver::GemResolver::Artifact.new(@graph, "listen", "2.0")
|
38
|
+
|
39
|
+
[artifact_2, artifact_1].sort.must_equal [artifact_1, artifact_2]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#dependencies" do
|
44
|
+
it "returns an array" do
|
45
|
+
@artifact.dependencies.must_be_kind_of Array
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns an empty array if no dependencies have been accessed" do
|
49
|
+
@artifact.dependencies.must_be_empty
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#depends" do
|
54
|
+
before do
|
55
|
+
@name = "nginx"
|
56
|
+
@constraint = "~> 0.101.5"
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "given a name and constraint argument" do
|
60
|
+
describe "given the dependency of the given name and constraint does not exist" do
|
61
|
+
it "returns a Solve::Artifact" do
|
62
|
+
@artifact.depends(@name, @constraint).must_be_kind_of Doubleshot::Resolver::GemResolver::Artifact
|
63
|
+
end
|
64
|
+
|
65
|
+
it "adds a dependency with the given name and constraint to the list of dependencies" do
|
66
|
+
@artifact.depends(@name, @constraint)
|
67
|
+
|
68
|
+
@artifact.dependencies.size.must_equal 1
|
69
|
+
@artifact.dependencies.first.name.must_equal @name
|
70
|
+
@artifact.dependencies.first.constraint.to_s.must_equal @constraint
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "given only a name argument" do
|
76
|
+
it "adds a dependency with a all constraint (>= 0.0.0)" do
|
77
|
+
@artifact.depends(@name)
|
78
|
+
|
79
|
+
@artifact.dependencies.size.must_equal 1
|
80
|
+
@artifact.dependencies.first.constraint.to_s.must_equal ">= 0"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "::get_dependency" do
|
86
|
+
|
87
|
+
it "returns an instance of Solve::Dependency matching the given name and constraint" do
|
88
|
+
@artifact.depends("nginx", "~> 1.2.3")
|
89
|
+
dependency = @artifact.get_dependency("nginx", "~> 1.2.3")
|
90
|
+
|
91
|
+
dependency.must_be_kind_of Doubleshot::Resolver::GemResolver::Dependency
|
92
|
+
dependency.name.must_equal "nginx"
|
93
|
+
dependency.constraint.to_s.must_equal "~> 1.2.3"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "#delete" do
|
98
|
+
|
99
|
+
describe "given the artifact is not the member of a graph" do
|
100
|
+
it "returns nil" do
|
101
|
+
artifact = Doubleshot::Resolver::GemResolver::Artifact.new(nil, "listen", "1.0")
|
102
|
+
artifact.delete.must_be_nil
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|