forked from Empact/roxml
-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Description
Option skip_parse on property is ignored when when corresponding value on input hash is nil.
Expected: when skip_parse: true representer does not try to set any value in represented model
Actual: representer tries to set value if value is nil
it 'representable skip_parse nil' do
class TestRepresenter < Representable::Decorator
include ::Representable::Hash
property :property1
property :property2, skip_parse: true
end
class TestModel
attr_accessor :property1
attr_reader :property2
def initialize
@property1 = '123'
@property2 = '456'
end
end
m = TestModel.new
r = TestRepresenter.new(m)
expected_hash = {property1: '123', property2: '456'}.stringify_keys
expect(r.to_hash).to eq(expected_hash)
new_hash = {property1: '789', property2: nil}.stringify_keys
r.from_hash(new_hash) # << fails here when trying to set readonly property2
expect(m.property1).to eq('789')
expect(m.property2).to eq('456')
endReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels