berkshelf-shims 0.1.0 → 0.1.1
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/Gemfile.lock +1 -1
- data/README.md +45 -1
- data/lib/berkshelf-shims/version.rb +1 -1
- data/lib/berkshelf-shims.rb +2 -0
- data/spec/berkshelf_shims_spec.rb +8 -4
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,48 @@
|
|
1
1
|
berkshelf-shims
|
2
2
|
===============
|
3
3
|
|
4
|
-
|
4
|
+
[](https://travis-ci.org/JeffBellegarde/berkshelf-shims)
|
5
|
+
|
6
|
+
Provide shims functionality for berkshelf.
|
7
|
+
|
8
|
+
Until https://github.com/RiotGames/berkshelf/pull/120 Berkshelf supported a --shims options that would create a directory of soft links referencing versioned cookbooks installed in the Berkshelf. Under the new Vagrant plugin, this was no longer needed and thus removed.
|
9
|
+
|
10
|
+
However, under [chefspec](https://github.com/acrmp/chefspec), the functionality is still useful. The gem provides equivalent functionality.
|
11
|
+
|
12
|
+
Just like Berkshelf used to do, berkshelf-shims creates a 'cookbook' directory in the same directory as the Berksfile and populates it with soft links.
|
13
|
+
|
14
|
+
Usage
|
15
|
+
-----
|
16
|
+
Setup Berkshelf as normal and generate a Berskfile.lock. Without the .lock file berkshelf-gems has nothing to read and will fail.
|
17
|
+
|
18
|
+
Add the gem to your Gemfile.
|
19
|
+
|
20
|
+
```
|
21
|
+
gem 'berkshelf-shims'
|
22
|
+
```
|
23
|
+
|
24
|
+
Add an appropriate hook for your testing framework.
|
25
|
+
|
26
|
+
#### RSpec hook
|
27
|
+
|
28
|
+
Put the following into spec/spec_helper.rb.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
require 'berkshelf-shims'
|
32
|
+
|
33
|
+
root_dir = File.join(File.dirname(__FILE__), '..')
|
34
|
+
RSpec.configure do |config|
|
35
|
+
config.before(:suite) do
|
36
|
+
BerkshelfShims::create_shims(root_dir)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
When instantiating the chef runner, pass in path to the created cookbook directory.
|
42
|
+
```ruby
|
43
|
+
ChefSpec::ChefRunner.new(:cookbook_path => "#{root_dir}/cookbooks")
|
44
|
+
```
|
45
|
+
|
46
|
+
Please notice that create_shims takes the root directory of the project while, ChefRunner.new needs the created 'cookbooks' directory.
|
47
|
+
|
48
|
+
|
data/lib/berkshelf-shims.rb
CHANGED
@@ -42,6 +42,8 @@ module BerkshelfShims
|
|
42
42
|
target = options[:path]
|
43
43
|
elsif options[:locked_version]
|
44
44
|
target = "#{berkshelf_path}/cookbooks/#{name}-#{options[:locked_version]}"
|
45
|
+
elsif options[:git] && options[:ref]
|
46
|
+
target = "#{berkshelf_path}/cookbooks/#{name}-#{options[:ref]}"
|
45
47
|
end
|
46
48
|
if target
|
47
49
|
FileUtils.ln_s(target, "#{cookbook_dir}/#{name}", :force => true)
|
@@ -36,7 +36,8 @@ describe BerkshelfShims do
|
|
36
36
|
context 'with a normal input' do
|
37
37
|
let(:cookbook_entries) {[
|
38
38
|
"cookbook 'relative', :path => '#{relative_target_dir}'",
|
39
|
-
"cookbook 'versioned', :locked_version => '0.0.1'"
|
39
|
+
"cookbook 'versioned', :locked_version => '0.0.1'",
|
40
|
+
"cookbook 'somegitrepo', :git => 'http://github.com/someuser/somegitrepo.git', :ref => '6ffb9cf5ddee65b8c208dec5c7b1ca9a4259b86a'"
|
40
41
|
]}
|
41
42
|
|
42
43
|
context 'with the default berkshelf path' do
|
@@ -45,9 +46,10 @@ describe BerkshelfShims do
|
|
45
46
|
end
|
46
47
|
it 'creates the links' do
|
47
48
|
Dir.exists?(cookbooks_dir).should == true
|
48
|
-
Dir["#{cookbooks_dir}/*"].sort.should == ["#{cookbooks_dir}/relative", "#{cookbooks_dir}/versioned"]
|
49
|
+
Dir["#{cookbooks_dir}/*"].sort.should == ["#{cookbooks_dir}/relative", "#{cookbooks_dir}/somegitrepo", "#{cookbooks_dir}/versioned"]
|
49
50
|
File.readlink("#{cookbooks_dir}/relative").should == '/Some/Directory'
|
50
51
|
File.readlink("#{cookbooks_dir}/versioned").should == "#{BerkshelfShims.berkshelf_path}/cookbooks/versioned-0.0.1"
|
52
|
+
File.readlink("#{cookbooks_dir}/somegitrepo").should == "#{BerkshelfShims.berkshelf_path}/cookbooks/somegitrepo-6ffb9cf5ddee65b8c208dec5c7b1ca9a4259b86a"
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
@@ -57,9 +59,10 @@ describe BerkshelfShims do
|
|
57
59
|
end
|
58
60
|
it 'creates the links' do
|
59
61
|
Dir.exists?(cookbooks_dir).should == true
|
60
|
-
Dir["#{cookbooks_dir}/*"].sort.should == ["#{cookbooks_dir}/relative", "#{cookbooks_dir}/versioned"]
|
62
|
+
Dir["#{cookbooks_dir}/*"].sort.should == ["#{cookbooks_dir}/relative", "#{cookbooks_dir}/somegitrepo", "#{cookbooks_dir}/versioned"]
|
61
63
|
File.readlink("#{cookbooks_dir}/relative").should == '/Some/Directory'
|
62
64
|
File.readlink("#{cookbooks_dir}/versioned").should == "berkshelf/cookbooks/versioned-0.0.1"
|
65
|
+
File.readlink("#{cookbooks_dir}/somegitrepo").should == "berkshelf/cookbooks/somegitrepo-6ffb9cf5ddee65b8c208dec5c7b1ca9a4259b86a"
|
63
66
|
end
|
64
67
|
end
|
65
68
|
|
@@ -70,9 +73,10 @@ describe BerkshelfShims do
|
|
70
73
|
end
|
71
74
|
it 'creates the links' do
|
72
75
|
Dir.exists?(cookbooks_dir).should == true
|
73
|
-
Dir["#{cookbooks_dir}/*"].sort.should == ["#{cookbooks_dir}/relative", "#{cookbooks_dir}/versioned"]
|
76
|
+
Dir["#{cookbooks_dir}/*"].sort.should == ["#{cookbooks_dir}/relative", "#{cookbooks_dir}/somegitrepo", "#{cookbooks_dir}/versioned"]
|
74
77
|
File.readlink("#{cookbooks_dir}/relative").should == '/Some/Directory'
|
75
78
|
File.readlink("#{cookbooks_dir}/versioned").should == "/berkshelf_env/cookbooks/versioned-0.0.1"
|
79
|
+
File.readlink("#{cookbooks_dir}/somegitrepo").should == "/berkshelf_env/cookbooks/somegitrepo-6ffb9cf5ddee65b8c208dec5c7b1ca9a4259b86a"
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: berkshelf-shims
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-22 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Shim functionality for Berkshelf
|
15
15
|
email:
|
@@ -45,7 +45,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
45
45
|
version: '0'
|
46
46
|
segments:
|
47
47
|
- 0
|
48
|
-
hash:
|
48
|
+
hash: 4057482081012609309
|
49
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
@@ -54,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
54
|
version: '0'
|
55
55
|
segments:
|
56
56
|
- 0
|
57
|
-
hash:
|
57
|
+
hash: 4057482081012609309
|
58
58
|
requirements: []
|
59
59
|
rubyforge_project:
|
60
60
|
rubygems_version: 1.8.23
|