summaryrefslogtreecommitdiff
path: root/spec/unit/resource_spec.rb
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-12-02 17:55:35 -0800
committerJohn Keiser <john@johnkeiser.com>2015-12-02 18:07:42 -0800
commit0c5ef9442d6fe8be5a9d0eb5d50ace124adeffd5 (patch)
tree3d8c709dc70407f1aadd98b10060b79626b72976 /spec/unit/resource_spec.rb
parent0b2cf51f77aa1988ad9af1110e36e5ce478af3ac (diff)
downloadchef-0c5ef9442d6fe8be5a9d0eb5d50ace124adeffd5.tar.gz
Make to_hash include properties with defaults (fixes #4127)jk/4127
Diffstat (limited to 'spec/unit/resource_spec.rb')
-rw-r--r--spec/unit/resource_spec.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index b433a8062d..59951941d7 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -439,6 +439,19 @@ describe Chef::Resource do
end
describe "to_hash" do
+ context "when the resource has a property with a default" do
+ let(:resource_class) { Class.new(Chef::Resource) { property :a, default: 1 } }
+ it "should include the default in the hash" do
+ expect(resource.to_hash.keys.sort).to eq([:a, :allowed_actions, :params, :provider, :updated,
+ :updated_by_last_action, :before, :supports,
+ :noop, :ignore_failure, :name, :source_line,
+ :action, :retries, :retry_delay, :elapsed_time,
+ :default_guard_interpreter, :guard_interpreter, :sensitive].sort)
+ expect(resource.to_hash[:name]).to eq "funk"
+ expect(resource.to_hash[:a]).to eq 1
+ end
+ end
+
it "should convert to a hash" do
hash = resource.to_hash
expected_keys = [ :allowed_actions, :params, :provider, :updated,