Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PDK-1007) Handle setting ensure to a Symbol through code #94

Merged
merged 1 commit into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/puppet/resource_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ def insync?(is)

define_method(:should=) do |value|
@shouldorig = value

if name == :ensure
value = value.to_s
end

# Puppet requires the @should value to always be stored as an array. We do not use this
# for anything else
# @see Puppet::Property.should=(value)
Expand Down
4 changes: 4 additions & 0 deletions spec/integration/resource_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ def get(_context)
end
end

it('ensure is reported as a symbol') { expect(instance[:ensure]).to be_a Symbol }
it('can set ensure to :present') { expect { instance[:ensure] = :present }.not_to raise_error }
it('can set ensure to :absent') { expect { instance[:ensure] = :absent }.not_to raise_error }

context 'when updating encounters an error' do
let(:setter) do
proc do |context, _changes|
Expand Down