chef-vault-testfixtures 0.4.0.20150424123749 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1cab73c11ad8e6ff474d55781924adac92429b55
4
- data.tar.gz: 6706ff2bd9cc0a310b8c39b366fbb1b8baf9872f
3
+ metadata.gz: 2c1145329f986e4edbf1b757f7e2b7d09b87c8b0
4
+ data.tar.gz: 6e474ea233078ca1fc0811b83fdcf3ddf333f471
5
5
  SHA512:
6
- metadata.gz: 98b1322d292df41c7d124c39c7042075cc2322b98059f2820466210c97d6ed2ced8e544014cd56040992bbc3d5bade1af3f37261ecddfcb6fae011ab1f848b46
7
- data.tar.gz: 0fea9ed27ed577f828cee69cb2c290334fc43bb2712d6c0cb09f807e81f684289651ce081886e5eb08b4eed092a29c8a935f8239568b90c8bcb84f6aedcdf98a
6
+ metadata.gz: a1f71a70286b72a489a2759ca0bdc77de747434c5bb4990c8f28991af3b9a2e7fbf785bf52718824c5bf1269a4a752dc781e73111aabed4624e9d3f8d3b8016a
7
+ data.tar.gz: d83dc649270a02559a29083467f1198fbcc55fab393b112b9b3de69de6e2ff4ef28af8cf3ce15d018f48fc8ebcc366dd72c0f52794ca15eb27e7e6d9c142804e
data/History.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog for chef-vault-testfixtures
2
2
 
3
+ ## 0.4.1
4
+
5
+ * fix bug where only the last item for a given vault was stubbed
6
+
3
7
  ## 0.4.0
4
8
 
5
9
  * add stubs for Chef::DataBagItem.load and Chef::DataBag.load for compatibility with code that probes the data bag to determine if it is a vault (e.g. chef-vault cookbook ~> 1.3)
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: chef-vault-testfixtures 0.4.0.20150424123749 ruby lib
2
+ # stub: chef-vault-testfixtures 0.4.1.20150424142230 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "chef-vault-testfixtures"
6
- s.version = "0.4.0.20150424123749"
6
+ s.version = "0.4.1.20150424142230"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
@@ -8,7 +8,7 @@ require 'chef-vault'
8
8
  class ChefVault
9
9
  # dynamic RSpec contexts for cookbooks that use chef-vault
10
10
  class TestFixtures
11
- VERSION = '0.4.0'
11
+ VERSION = '0.4.1'
12
12
 
13
13
  # dynamically creates a memoized RSpec shared context
14
14
  # that when included into an example group will stub
@@ -35,17 +35,18 @@ class ChefVault
35
35
  end
36
36
 
37
37
  def stub_vault(vault)
38
+ db = {}
38
39
  vault.each_child do |e|
39
40
  next unless e.file?
40
41
  m = e.basename.to_s.downcase.match(/(.+)\.json/i)
41
- stub_vault_item(vault.basename.to_s, m[1], e.read) if m
42
+ stub_vault_item(vault.basename.to_s, m[1], e.read, db) if m
42
43
  end
43
44
  end
44
45
 
45
- def stub_vault_item(vault, item, json)
46
+ def stub_vault_item(vault, item, json, db)
46
47
  content = JSON.parse(json)
47
- db = make_fakedatabag(vault, item)
48
- dbi = make_fakedatabagitem(vault, item)
48
+ db["#{item}_keys"] = true
49
+ dbi = {}
49
50
  vi = make_fakevault(vault, item)
50
51
 
51
52
  # stub lookup of each of the vault item keys
@@ -76,20 +77,6 @@ class ChefVault
76
77
  end
77
78
  end
78
79
 
79
- def make_fakedatabagitem(_, _)
80
- {}
81
- end
82
-
83
- def make_fakedatabag(vault, item)
84
- db = double "databag #{vault}"
85
- %w(key? has_key?).each do |pred|
86
- allow(db).to(receive(pred.to_sym)
87
- .with("#{item}_keys")
88
- .and_return(true))
89
- end
90
- db
91
- end
92
-
93
80
  def make_fakevault(vault, item)
94
81
  fakevault = double "vault item #{vault}/#{item}"
95
82
  allow(fakevault).to receive(:[]=).with(String, Object)
@@ -52,13 +52,13 @@ RSpec.describe ChefVault::TestFixtures do
52
52
  expect(baz).to eq(1)
53
53
  end
54
54
 
55
- it 'should allow access to the aliased bar/gzonk vault item' do
55
+ it 'should allow access to the bar/gzonk vault item' do
56
56
  item1 = ChefVault::Item.load('bar', 'foo')
57
57
  item2 = ChefVault::Item.load('bar', 'gzonk')
58
58
  expect(item1['baz']).to eq(item2['baz'])
59
59
  end
60
60
 
61
- it 'should allow access to the aliased bar/gzonk vault item via a symbol' do
61
+ it 'should allow access to the bar/gzonk vault item via a symbol' do
62
62
  item1 = ChefVault::Item.load(:bar, 'foo')
63
63
  item2 = ChefVault::Item.load(:bar, 'gzonk')
64
64
  expect(item1['baz']).to eq(item2['baz'])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-vault-testfixtures
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.20150424123749
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James FitzGibbon
@@ -277,4 +277,3 @@ summary: chef-vault-testfixtures provides an RSpec shared context that stubs acc
277
277
  to chef-vault encrypted data bags using the same fallback mechanism as the `chef_vault_item`
278
278
  helper from the [chef-vault cookbook](https://supermarket.chef.io/cookbooks/chef-vault)
279
279
  test_files: []
280
- has_rdoc: