spec/chef-vault/item_spec.rb in chef-vault-3.0.0.rc1 vs spec/chef-vault/item_spec.rb in chef-vault-3.0.0.rc2
- old
+ new
@@ -170,10 +170,11 @@
expect { item.save }.to raise_error(ChefVault::Exceptions::IdMismatch)
end
end
describe "#refresh" do
+ let(:node) { { "name" => "testnode" } }
it "saves only the keys" do
keys = double("keys",
search_query: "*:*",
add: nil,
@@ -182,11 +183,10 @@
allow(keys).to receive(:[]).with("id").and_return("bar_keys")
allow(ChefVault::ItemKeys).to receive(:new).and_return(keys)
item = ChefVault::Item.new("foo", "bar")
- node = double("node", name: "testnode")
query = double("query")
allow(Chef::Search::Query).to receive(:new).and_return(query)
allow(query).to receive(:search).and_yield(node)
client_key = double("client_key",
@@ -200,32 +200,30 @@
end
end
describe "#clients" do
context "when search returns a node with a valid client backing it and one without a valid client" do
- let(:node_with_valid_client) { double("chef node valid") }
- let(:node_without_valid_client) { double("chef node no valid client") }
+ let(:node_with_valid_client) { { "name" => "foo" } }
+ let(:node_without_valid_client) { { "name" => "bar" } }
let(:query_result) { double("chef search results") }
let(:client_key) { double("chef key") }
before do
# node with valid client proper loads client key
- allow(node_with_valid_client).to receive(:name).and_return("foo")
allow(item).to receive(:load_actor).with("foo", "clients").and_return(client_key)
privkey = OpenSSL::PKey::RSA.new(1024)
pubkey = privkey.public_key
allow(client_key).to receive(:key).and_return(pubkey.to_pem)
allow(client_key).to receive(:name).and_return("foo")
allow(client_key).to receive(:type).and_return("clients")
# node without client throws relevant error on key load
- allow(node_without_valid_client).to receive(:name).and_return("bar")
allow(item).to receive(:load_actor).with("bar", "clients").and_raise(ChefVault::Exceptions::ClientNotFound)
allow(query_result)
.to receive(:search)
- .with(Symbol, String)
+ .with(Symbol, String, Hash)
.and_yield(node_with_valid_client).and_yield(node_without_valid_client)
allow(Chef::Search::Query)
.to receive(:new)
.and_return(query_result)
end
@@ -304,10 +302,10 @@
allow(client_key).to receive(:name).and_return(client_name)
allow(client_key).to receive(:type).and_return("clients")
end
context "when no action is passed" do
- it "default to add and properly add the client" do
+ it "defaults to add and properly adds the client" do
item.clients(clients)
expect(item.get_clients).to include(client_name)
end
it "does not perform a query" do