spec/hashie/extensions/ignore_undeclared_spec.rb in hashie-3.4.3 vs spec/hashie/extensions/ignore_undeclared_spec.rb in hashie-3.4.4
- old
+ new
@@ -4,10 +4,11 @@
context 'included in Trash' do
class ForgivingTrash < Hashie::Trash
include Hashie::Extensions::IgnoreUndeclared
property :city
property :state, from: :provence
+ property :str_state, from: 'str_provence'
end
subject { ForgivingTrash }
it 'silently ignores undeclared properties on initialization' do
@@ -17,10 +18,10 @@
it 'works with translated properties (with symbol keys)' do
expect(subject.new(provence: 'Ontario').state).to eq('Ontario')
end
it 'works with translated properties (with string keys)' do
- expect(subject.new(provence: 'Ontario').state).to eq('Ontario')
+ expect(subject.new('str_provence' => 'Ontario').str_state).to eq('Ontario')
end
it 'requires properties to be declared on assignment' do
hash = subject.new(city: 'Toronto')
expect { hash.country = 'Canada' }.to raise_error(NoMethodError)