Sha256: b62e39e4dcacc027f5ffeabfce29230cb310f9010c7e8d5c971f9eda93252c4a
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
require 'spec_helper' describe Ridley::DataBagItem do let(:connection) { double('connection') } let(:data_bag) { double('data_bag') } subject { Ridley::DataBagItem.new(connection, data_bag) } describe "::from_hash" do context "when JSON has a 'raw_data' field" do let(:response) do { "name" => "data_bag_item_ridley-test_appconfig", "raw_data" => { "id" => "appconfig", "host" => "host.local" }, "json_class" => "Chef::DataBagItem", "data_bag" => "ridley-test", "chef_type" => "data_bag_item" } end it "returns a new object from attributes in the 'raw_data' field" do subject.from_hash(response).attributes.should eql(response["raw_data"]) end end context "when JSON does not contain a 'raw_data' field" do let(:response) do { "id" => "appconfig", "host" => "host.local" } end it "returns a new object from the hash" do subject.from_hash(response).attributes.should eql(response) end end end describe "#decrypt" do it "decrypts an encrypted item" do encrypted_data_bag_secret = File.read(fixtures_path.join("encrypted_data_bag_secret").to_s) connection.stub(:encrypted_data_bag_secret).and_return(encrypted_data_bag_secret) subject.attributes[:test] = "Xk0E8lV9r4BhZzcg4wal0X4w9ZexN3azxMjZ9r1MCZc=" subject.decrypt subject.attributes[:test][:database][:username].should == "test" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ridley-0.5.0 | spec/unit/ridley/resources/data_bag_item_spec.rb |