librarian-puppet 0.9.1 → 0.9.2.pre

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 (52) hide show
  1. data/lib/librarian/puppet.rb +6 -1
  2. data/lib/librarian/puppet/cli.rb +21 -0
  3. data/lib/librarian/puppet/environment.rb +1 -0
  4. data/lib/librarian/puppet/lockfile/parser.rb +53 -0
  5. data/lib/librarian/puppet/source/forge.rb +0 -8
  6. data/lib/librarian/puppet/source/git.rb +29 -0
  7. data/lib/librarian/puppet/source/local.rb +1 -0
  8. data/lib/librarian/puppet/version.rb +5 -0
  9. data/vendor/librarian/CHANGELOG.md +17 -0
  10. data/vendor/librarian/Gemfile +2 -0
  11. data/vendor/librarian/README.md +99 -14
  12. data/vendor/librarian/features/chef/cli/init.feature +1 -0
  13. data/vendor/librarian/features/chef/cli/show.feature +13 -1
  14. data/vendor/librarian/lib/librarian/action/base.rb +6 -4
  15. data/vendor/librarian/lib/librarian/chef/cli.rb +21 -0
  16. data/vendor/librarian/lib/librarian/chef/environment.rb +9 -1
  17. data/vendor/librarian/lib/librarian/chef/manifest_reader.rb +14 -2
  18. data/vendor/librarian/lib/librarian/chef/source/git.rb +13 -0
  19. data/vendor/librarian/lib/librarian/chef/source/local.rb +8 -2
  20. data/vendor/librarian/lib/librarian/chef/source/site.rb +18 -6
  21. data/vendor/librarian/lib/librarian/cli.rb +54 -24
  22. data/vendor/librarian/lib/librarian/config.rb +7 -0
  23. data/vendor/librarian/lib/librarian/config/database.rb +205 -0
  24. data/vendor/librarian/lib/librarian/config/file_source.rb +47 -0
  25. data/vendor/librarian/lib/librarian/config/hash_source.rb +33 -0
  26. data/vendor/librarian/lib/librarian/config/source.rb +149 -0
  27. data/vendor/librarian/lib/librarian/dependency.rb +1 -5
  28. data/vendor/librarian/lib/librarian/dsl.rb +6 -3
  29. data/vendor/librarian/lib/librarian/dsl/target.rb +0 -4
  30. data/vendor/librarian/lib/librarian/environment.rb +30 -25
  31. data/vendor/librarian/lib/librarian/lockfile.rb +0 -4
  32. data/vendor/librarian/lib/librarian/lockfile/compiler.rb +0 -4
  33. data/vendor/librarian/lib/librarian/lockfile/parser.rb +4 -8
  34. data/vendor/librarian/lib/librarian/logger.rb +46 -0
  35. data/vendor/librarian/lib/librarian/manifest.rb +1 -9
  36. data/vendor/librarian/lib/librarian/resolver.rb +6 -1
  37. data/vendor/librarian/lib/librarian/resolver/implementation.rb +1 -5
  38. data/vendor/librarian/lib/librarian/source/git/repository.rb +10 -6
  39. data/vendor/librarian/lib/librarian/source/local.rb +12 -2
  40. data/vendor/librarian/lib/librarian/spec_change_set.rb +6 -3
  41. data/vendor/librarian/lib/librarian/specfile.rb +0 -4
  42. data/vendor/librarian/lib/librarian/version.rb +1 -1
  43. data/vendor/librarian/librarian.gemspec +1 -0
  44. data/vendor/librarian/spec/functional/source/git/repository_spec.rb +149 -0
  45. data/vendor/librarian/spec/unit/config/database_spec.rb +319 -0
  46. data/vendor/librarian/spec/unit/dependency_spec.rb +6 -0
  47. data/vendor/librarian/spec/unit/manifest_spec.rb +6 -0
  48. metadata +107 -66
  49. data/librarian-puppet.gemspec +0 -130
  50. data/vendor/librarian/.rspec +0 -1
  51. data/vendor/librarian/.travis.yml +0 -6
  52. data/vendor/librarian/lib/librarian/helpers/debug.rb +0 -35
@@ -0,0 +1,46 @@
1
+ module Librarian
2
+ class Logger
3
+
4
+ librarian_path = Pathname(__FILE__)
5
+ librarian_path = librarian_path.dirname until librarian_path.join("lib").directory?
6
+ LIBRARIAN_PATH = librarian_path
7
+
8
+ attr_accessor :environment
9
+ private :environment=
10
+
11
+ def initialize(environment)
12
+ self.environment = environment
13
+ end
14
+
15
+ def info(string = nil, &block)
16
+ return unless ui
17
+
18
+ ui.info(string || yield)
19
+ end
20
+
21
+ def debug(string = nil, &block)
22
+ return unless ui
23
+
24
+ if ui.respond_to?(:debug_line_numbers) && ui.debug_line_numbers
25
+ loc = caller.find{|l| !(l =~ /in `debug'$/)}
26
+ if loc =~ /^(.+):(\d+):in `(.+)'$/
27
+ loc = "#{Pathname.new($1).relative_path_from(LIBRARIAN_PATH)}:#{$2}:in `#{$3}'"
28
+ end
29
+ ui.debug { "[Librarian] #{string || yield} [#{loc}]" }
30
+ else
31
+ ui.debug { "[Librarian] #{string || yield}" }
32
+ end
33
+ end
34
+
35
+ def relative_path_to(path)
36
+ environment.project_relative_path_to(path)
37
+ end
38
+
39
+ private
40
+
41
+ def ui
42
+ environment.ui
43
+ end
44
+
45
+ end
46
+ end
@@ -1,8 +1,5 @@
1
1
  require 'rubygems'
2
2
 
3
- require 'librarian/helpers/debug'
4
- require 'librarian/support/abstract_method'
5
-
6
3
  module Librarian
7
4
  class Manifest
8
5
 
@@ -39,14 +36,9 @@ module Librarian
39
36
  attr_accessor :backing
40
37
  end
41
38
 
42
- include Support::AbstractMethod
43
- include Helpers::Debug
44
-
45
39
  attr_accessor :source, :name, :extra
46
40
  private :source=, :name=, :extra=
47
41
 
48
- abstract_method :fetch_version!, :fetch_dependencies!
49
-
50
42
  def initialize(source, name, extra = nil)
51
43
  assert_name_valid! name
52
44
 
@@ -133,7 +125,7 @@ module Librarian
133
125
  end
134
126
 
135
127
  def assert_name_valid!(name)
136
- raise ArgumentError, "name (#{name.inspect}) must be sensible" unless name =~ /^\S.*\S$/
128
+ raise ArgumentError, "name (#{name.inspect}) must be sensible" unless name =~ /\A\S(?:.*\S)?\z/
137
129
  end
138
130
 
139
131
  end
@@ -4,7 +4,6 @@ require 'librarian/resolution'
4
4
 
5
5
  module Librarian
6
6
  class Resolver
7
- include Helpers::Debug
8
7
 
9
8
  attr_accessor :environment
10
9
  private :environment=
@@ -69,5 +68,11 @@ module Librarian
69
68
  ManifestSet.sort(manifests)
70
69
  end
71
70
 
71
+ private
72
+
73
+ def debug(*args, &block)
74
+ environment.logger.debug(*args, &block)
75
+ end
76
+
72
77
  end
73
78
  end
@@ -1,13 +1,9 @@
1
- require 'librarian/helpers/debug'
2
-
3
1
  require 'librarian/dependency'
4
2
 
5
3
  module Librarian
6
4
  class Resolver
7
5
  class Implementation
8
6
 
9
- include Helpers::Debug
10
-
11
7
  attr_reader :resolver, :source, :dependency_source_map
12
8
 
13
9
  def initialize(resolver, spec)
@@ -110,7 +106,7 @@ module Librarian
110
106
  end
111
107
 
112
108
  def debug
113
- super { ' ' * @level + yield }
109
+ environment.logger.debug { ' ' * @level + yield }
114
110
  end
115
111
 
116
112
  def environment
@@ -1,7 +1,5 @@
1
1
  require 'open3'
2
2
 
3
- require 'librarian/helpers/debug'
4
-
5
3
  module Librarian
6
4
  module Source
7
5
  class Git
@@ -34,15 +32,13 @@ module Librarian
34
32
  path = File.expand_path(path)
35
33
  exts.each do |ext|
36
34
  exe = File.join(path, cmd + ext)
37
- return exe if File.executable?(exe)
35
+ return exe if File.file?(exe) && File.executable?(exe)
38
36
  end
39
37
  end
40
38
  nil
41
39
  end
42
40
  end
43
41
 
44
- include Helpers::Debug
45
-
46
42
  attr_accessor :environment, :path
47
43
  private :environment=, :path=
48
44
 
@@ -127,7 +123,7 @@ module Librarian
127
123
  reference = "#{remote}/#{reference}"
128
124
  end
129
125
 
130
- command = %W(rev-parse #{reference} --quiet)
126
+ command = %W(rev-list #{reference} -1)
131
127
  run!(command, :chdir => true).strip
132
128
  end
133
129
 
@@ -207,6 +203,14 @@ module Librarian
207
203
  end
208
204
  end
209
205
 
206
+ def debug(*args, &block)
207
+ environment.logger.debug(*args, &block)
208
+ end
209
+
210
+ def relative_path_to(path)
211
+ environment.logger.relative_path_to(path)
212
+ end
213
+
210
214
  end
211
215
  end
212
216
  end
@@ -1,4 +1,3 @@
1
- require 'librarian/helpers/debug'
2
1
  require 'librarian/support/abstract_method'
3
2
 
4
3
  module Librarian
@@ -8,7 +7,6 @@ module Librarian
8
7
  # #environment
9
8
  module Local
10
9
 
11
- include Helpers::Debug
12
10
  include Support::AbstractMethod
13
11
 
14
12
  abstract_method :path, :fetch_version, :fetch_dependencies
@@ -46,6 +44,18 @@ module Librarian
46
44
 
47
45
  abstract_method :manifest? # (name, path) -> boolean
48
46
 
47
+ def info(*args, &block)
48
+ environment.logger.info(*args, &block)
49
+ end
50
+
51
+ def debug(*args, &block)
52
+ environment.logger.debug(*args, &block)
53
+ end
54
+
55
+ def relative_path_to(path)
56
+ environment.logger.relative_path_to(path)
57
+ end
58
+
49
59
  end
50
60
  end
51
61
  end
@@ -1,5 +1,4 @@
1
1
  require 'librarian/helpers'
2
- require 'librarian/helpers/debug'
3
2
 
4
3
  require 'librarian/manifest_set'
5
4
  require 'librarian/resolution'
@@ -8,8 +7,6 @@ require 'librarian/spec'
8
7
  module Librarian
9
8
  class SpecChangeSet
10
9
 
11
- include Helpers::Debug
12
-
13
10
  attr_accessor :environment
14
11
  private :environment=
15
12
  attr_reader :spec, :lock
@@ -166,5 +163,11 @@ module Librarian
166
163
  end
167
164
  end
168
165
 
166
+ private
167
+
168
+ def debug(*args, &block)
169
+ environment.logger.debug(*args, &block)
170
+ end
171
+
169
172
  end
170
173
  end
@@ -1,10 +1,6 @@
1
- require 'librarian/helpers/debug'
2
-
3
1
  module Librarian
4
2
  class Specfile
5
3
 
6
- include Helpers::Debug
7
-
8
4
  attr_accessor :environment
9
5
  private :environment=
10
6
  attr_reader :path, :dependencies, :source
@@ -1,3 +1,3 @@
1
1
  module Librarian
2
- VERSION = "0.0.23"
2
+ VERSION = "0.0.24"
3
3
  end
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.add_development_dependency "cucumber"
27
27
  s.add_development_dependency "aruba"
28
28
  s.add_development_dependency "webmock"
29
+ s.add_development_dependency "fakefs"
29
30
 
30
31
  s.add_dependency "chef", ">= 0.10"
31
32
  s.add_dependency "highline"
@@ -0,0 +1,149 @@
1
+ require "fileutils"
2
+ require "pathname"
3
+ require "securerandom"
4
+
5
+ require "librarian/source/git/repository"
6
+
7
+ describe Librarian::Source::Git::Repository do
8
+
9
+ let(:env) do
10
+ double(:ui => nil, :logger => double(:debug => nil, :info => nil))
11
+ end
12
+
13
+ let(:project_path) do
14
+ project_path = Pathname.new(__FILE__).expand_path
15
+ project_path = project_path.dirname until project_path.join("Rakefile").exist?
16
+ project_path
17
+ end
18
+ let(:tmp_path) { project_path + "tmp/spec/unit/source/git/repository-spec" }
19
+ let(:git_source_path) { tmp_path + SecureRandom.hex(16) }
20
+ let(:branch) { "the-branch" }
21
+ let(:tag) { "the-tag" }
22
+ let(:atag) { "the-atag" }
23
+
24
+ before do
25
+ git_source_path.mkpath
26
+ Dir.chdir(git_source_path) do
27
+ `git init`
28
+
29
+ # master
30
+ `touch butter.txt`
31
+ `git add butter.txt`
32
+ `git commit -m "Initial Commit"`
33
+
34
+ # branch
35
+ `git checkout -b #{branch} --quiet`
36
+ `touch jam.txt`
37
+ `git add jam.txt`
38
+ `git commit -m "Branch Commit"`
39
+ `git checkout master --quiet`
40
+
41
+ # tag
42
+ `git checkout -b deletable --quiet`
43
+ `touch jelly.txt`
44
+ `git add jelly.txt`
45
+ `git commit -m "Tag Commit"`
46
+ `git tag #{tag}`
47
+ `git checkout master --quiet`
48
+ `git branch -D deletable`
49
+
50
+ # annotated tag
51
+ `git checkout -b deletable --quiet`
52
+ `touch jelly.txt`
53
+ `git add jelly.txt`
54
+ `git commit -m "Tag Commit"`
55
+ `git tag -am "Annotated Tag Commit" #{atag}`
56
+ `git checkout master --quiet`
57
+ `git branch -D deletable`
58
+ end
59
+ end
60
+
61
+ context "the original" do
62
+ subject { described_class.new(env, git_source_path) }
63
+
64
+ it "should recognize it" do
65
+ subject.should be_git
66
+ end
67
+
68
+ it "should not list any remotes for it" do
69
+ subject.remote_names.should be_empty
70
+ end
71
+
72
+ it "should not list any remote branches for it" do
73
+ subject.remote_branch_names.should be_empty
74
+ end
75
+ end
76
+
77
+ context "a clone" do
78
+ let(:git_clone_path) { tmp_path + SecureRandom.hex(16) }
79
+ subject { described_class.clone!(env, git_clone_path, git_source_path) }
80
+
81
+ let(:master_sha) { subject.hash_from("origin", "master") }
82
+ let(:branch_sha) { subject.hash_from("origin", branch) }
83
+ let(:tag_sha) { subject.hash_from("origin", tag) }
84
+ let(:atag_sha) { subject.hash_from("origin", atag) }
85
+
86
+ it "should recognize it" do
87
+ subject.should be_git
88
+ end
89
+
90
+ it "should have a single remote for it" do
91
+ subject.should have(1).remote_names
92
+ end
93
+
94
+ it "should have a remote with the expected name" do
95
+ subject.remote_names.first.should == "origin"
96
+ end
97
+
98
+ it "should have the remote branch" do
99
+ subject.remote_branch_names["origin"].should include branch
100
+ end
101
+
102
+ it "should be checked out on the master" do
103
+ subject.should be_checked_out(master_sha)
104
+ end
105
+
106
+ context "checking out the branch" do
107
+ before do
108
+ subject.checkout! branch
109
+ end
110
+
111
+ it "should be checked out on the branch" do
112
+ subject.should be_checked_out(branch_sha)
113
+ end
114
+
115
+ it "should not be checked out on the master" do
116
+ subject.should_not be_checked_out(master_sha)
117
+ end
118
+ end
119
+
120
+ context "checking out the tag" do
121
+ before do
122
+ subject.checkout! tag
123
+ end
124
+
125
+ it "should be checked out on the tag" do
126
+ subject.should be_checked_out(tag_sha)
127
+ end
128
+
129
+ it "should not be checked out on the master" do
130
+ subject.should_not be_checked_out(master_sha)
131
+ end
132
+ end
133
+
134
+ context "checking out the annotated tag" do
135
+ before do
136
+ subject.checkout! atag
137
+ end
138
+
139
+ it "should be checked out on the annotated tag" do
140
+ subject.should be_checked_out(atag_sha)
141
+ end
142
+
143
+ it "should not be checked out on the master" do
144
+ subject.should_not be_checked_out(master_sha)
145
+ end
146
+ end
147
+ end
148
+
149
+ end
@@ -0,0 +1,319 @@
1
+ require "fileutils"
2
+ require "pathname"
3
+ require "yaml"
4
+
5
+ require "fakefs/spec_helpers"
6
+
7
+ require "librarian/config/database"
8
+
9
+ describe Librarian::Config::Database do
10
+ include FakeFS::SpecHelpers
11
+
12
+ def write_yaml!(path, *yamlables)
13
+ dir = File.dirname(path)
14
+ FileUtils.mkpath(dir) unless File.directory?(dir)
15
+ File.open(path, "wb"){|f| yamlables.each{|y| YAML.dump(y, f)}}
16
+ end
17
+
18
+ let(:adapter_name) { "gem" }
19
+
20
+ let(:env) { { } }
21
+ let(:pwd) { Pathname("/tmp") }
22
+ let(:home) { Pathname("~").expand_path }
23
+ let(:project_path) { nil }
24
+ let(:specfile_name) { nil }
25
+ let(:global) { home.join(".librarian/gem/config") }
26
+ let(:local) { pwd.join(".librarian/gem/config") }
27
+ let(:specfile) { pwd.join("Gemfile") }
28
+
29
+ before do
30
+ FileUtils.mkpath(pwd)
31
+ FileUtils.touch(specfile)
32
+ end
33
+
34
+ let(:database) do
35
+ described_class.new(adapter_name,
36
+ :env => env,
37
+ :pwd => pwd.to_s,
38
+ :home => home.to_s,
39
+ :project_path => project_path,
40
+ :specfile_name => specfile_name
41
+ )
42
+ end
43
+
44
+ context "when a key is given globally" do
45
+ let(:key) { "jam" }
46
+ let(:value) { "jelly" }
47
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
48
+
49
+ before do
50
+ write_yaml! global, raw_key => value
51
+ end
52
+
53
+ it "should have the key globally" do
54
+ database.global[key].should == value
55
+ end
56
+
57
+ it "should not have the key in the env" do
58
+ database.env[key].should be_nil
59
+ end
60
+
61
+ it "should not have the key locally" do
62
+ database.local[key].should be_nil
63
+ end
64
+
65
+ it "should have the key generally" do
66
+ database[key].should == value
67
+ end
68
+ end
69
+
70
+ context "when a key is set globally" do
71
+ let(:key) { "jam" }
72
+ let(:value) { "jelly" }
73
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
74
+
75
+ before do
76
+ database.global[key] = value
77
+ end
78
+
79
+ it "should have the key globally" do
80
+ database.global[key].should == value
81
+ end
82
+
83
+ it "should not have the key in the env" do
84
+ database.env[key].should be_nil
85
+ end
86
+
87
+ it "should not have the key locally" do
88
+ database.local[key].should be_nil
89
+ end
90
+
91
+ it "should have the key generally" do
92
+ database[key].should == value
93
+ end
94
+
95
+ it "should persist the key" do
96
+ data = YAML.load_file(global)
97
+
98
+ data.should == {raw_key => value}
99
+ end
100
+ end
101
+
102
+ context "when the key is set and unset globally" do
103
+ let(:key) { "jam" }
104
+ let(:value) { "jelly" }
105
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
106
+
107
+ before do
108
+ database.global[key] = value
109
+ database.global[key] = nil
110
+ end
111
+
112
+ it "should not have the key globally" do
113
+ database.global[key].should be_nil
114
+ end
115
+
116
+ it "should not have the key in the env" do
117
+ database.env[key].should be_nil
118
+ end
119
+
120
+ it "should not have the key locally" do
121
+ database.local[key].should be_nil
122
+ end
123
+
124
+ it "should not have the key generally" do
125
+ database[key].should be_nil
126
+ end
127
+
128
+ it "should unpersist the key" do
129
+ File.should_not exist global
130
+ end
131
+ end
132
+
133
+ context "when a key is given in the env" do
134
+ let(:key) { "jam" }
135
+ let(:value) { "jelly" }
136
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
137
+
138
+ #override
139
+ let(:env) { {raw_key => value} }
140
+
141
+ it "should not have the key globally" do
142
+ database.global[key].should be_nil
143
+ end
144
+
145
+ it "should have the key in the env" do
146
+ database.env[key].should == value
147
+ end
148
+
149
+ it "should not have the key locally" do
150
+ database.local[key].should be_nil
151
+ end
152
+
153
+ it "should have the key generally" do
154
+ database[key].should == value
155
+ end
156
+ end
157
+
158
+ context "when a key is given locally" do
159
+ let(:key) { "jam" }
160
+ let(:value) { "jelly" }
161
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
162
+
163
+ before do
164
+ write_yaml! local, raw_key => value
165
+ end
166
+
167
+ it "should not have the key globally" do
168
+ database.global[key].should be_nil
169
+ end
170
+
171
+ it "should not have the key in the env" do
172
+ database.env[key].should be_nil
173
+ end
174
+
175
+ it "should have the key locally" do
176
+ database.local[key].should == value
177
+ end
178
+
179
+ it "should have the key generally" do
180
+ database[key].should == value
181
+ end
182
+ end
183
+
184
+ context "when a key is set locally" do
185
+ let(:key) { "jam" }
186
+ let(:value) { "jelly" }
187
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
188
+
189
+ before do
190
+ database.local[key] = value
191
+ end
192
+
193
+ it "should not have the key globally" do
194
+ database.global[key].should be_nil
195
+ end
196
+
197
+ it "should not have the key in the env" do
198
+ database.env[key].should be_nil
199
+ end
200
+
201
+ it "should have the key locally" do
202
+ database.local[key].should == value
203
+ end
204
+
205
+ it "should have the key generally" do
206
+ database[key].should == value
207
+ end
208
+
209
+ it "should persist the key" do
210
+ data = YAML.load_file(local)
211
+
212
+ data.should == {raw_key => value}
213
+ end
214
+ end
215
+
216
+ context "when the key is set and unset locally" do
217
+ let(:key) { "jam" }
218
+ let(:value) { "jelly" }
219
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
220
+
221
+ before do
222
+ database.local[key] = value
223
+ database.local[key] = nil
224
+ end
225
+
226
+ it "should not have the key globally" do
227
+ database.global[key].should be_nil
228
+ end
229
+
230
+ it "should not have the key in the env" do
231
+ database.env[key].should be_nil
232
+ end
233
+
234
+ it "should not have the key locally" do
235
+ database.local[key].should be_nil
236
+ end
237
+
238
+ it "should not have the key generally" do
239
+ database[key].should be_nil
240
+ end
241
+
242
+ it "should unpersist the key" do
243
+ File.should_not exist local
244
+ end
245
+ end
246
+
247
+ context "setting malformatted keys" do
248
+ it "should ban caps" do
249
+ expect { database.global["JAM"] = "jelly" }.
250
+ to raise_error Librarian::Error, %[key not permitted: "JAM"]
251
+ end
252
+
253
+ it "should ban double dots" do
254
+ expect { database.global["jam..jam"] = "jelly" }.
255
+ to raise_error Librarian::Error, %[key not permitted: "jam..jam"]
256
+ end
257
+ end
258
+
259
+ context "setting banned keys" do
260
+ it "should ban the specfile key" do
261
+ expect { database.global["gemfile"] = "jelly" }.
262
+ to raise_error Librarian::Error, %[key not permitted: "gemfile"]
263
+ end
264
+
265
+ it "should ban the global-config key" do
266
+ expect { database.global["config"] = "jelly" }.
267
+ to raise_error Librarian::Error, %[key not permitted: "config"]
268
+ end
269
+ end
270
+
271
+ context "project_path" do
272
+ context "by default" do
273
+ it "should give the default project path" do
274
+ database.project_path.should == Pathname("/tmp")
275
+ end
276
+ end
277
+
278
+ context "when the specfile is set in the env" do
279
+ let(:env) { {"LIBRARIAN_GEM_GEMFILE" => "/non/sense/path/to/Sillyfile"} }
280
+
281
+ it "should give the project path from the env-set specfile" do
282
+ database.project_path.should == Pathname("/non/sense/path/to")
283
+ end
284
+ end
285
+ end
286
+
287
+ context "specfile_path" do
288
+ context "by default" do
289
+ it "should give the default specfile path" do
290
+ database.specfile_path.should == specfile
291
+ end
292
+ end
293
+
294
+ context "when set in the env" do
295
+ let(:env) { {"LIBRARIAN_GEM_GEMFILE" => "/non/sense/path/to/Sillyfile"} }
296
+
297
+ it "should give the given specfile path" do
298
+ database.specfile_path.should == Pathname("/non/sense/path/to/Sillyfile")
299
+ end
300
+ end
301
+
302
+ context "when the project_path is assigned" do
303
+ let(:project_path) { "/non/sense/path/to" }
304
+
305
+ it "should give the assigned specfile path" do
306
+ database.specfile_path.should == Pathname("/non/sense/path/to/Gemfile")
307
+ end
308
+ end
309
+
310
+ context "when the specfile_name is assigned" do
311
+ let(:specfile_name) { "Sillyfile" }
312
+
313
+ it "should give the assigned specfile path" do
314
+ database.specfile_path.should == Pathname("/tmp/Sillyfile")
315
+ end
316
+ end
317
+ end
318
+
319
+ end