summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Herold <michael.j.herold@gmail.com>2014-08-23 20:24:44 -0400
committerdB <dblock@dblock.org>2014-08-23 20:24:44 -0400
commit32d5b0488145982bb0f35920ddb4f879e121d4d5 (patch)
tree3e5bd8aa3b217d9aaba2c0823deab8392321effc
parent65dd4496ea86d0a71b190a58038d1955f19ba84a (diff)
downloadhashie-32d5b0488145982bb0f35920ddb4f879e121d4d5.tar.gz
Add failing spec for #69.
-rw-r--r--spec/hashie/trash_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/hashie/trash_spec.rb b/spec/hashie/trash_spec.rb
index e844093..f85b09c 100644
--- a/spec/hashie/trash_spec.rb
+++ b/spec/hashie/trash_spec.rb
@@ -134,6 +134,25 @@ describe Hashie::Trash do
end
end
+ describe 'translating multiple properties using a proc' do
+ class SomeDataModel < Hashie::Trash
+ property :value_a, from: :config, with: ->(config) { config.a }
+ property :value_b, from: :config, with: ->(config) { config.b }
+ end
+
+ ConfigDataModel = Struct.new(:a, :b)
+
+ subject { SomeDataModel.new(config: ConfigDataModel.new('value in a', 'value in b')) }
+
+ it 'translates the first key' do
+ expect(subject.value_a).to eq 'value in a'
+ end
+
+ it 'translates the second key' do
+ expect(subject.value_b).to eq 'value in b'
+ end
+ end
+
describe 'uses with or transform_with interchangeably' do
class TrashLambdaTestTransformWith < Hashie::Trash
property :first_name, from: :firstName, transform_with: ->(value) { value.reverse }