Skip to content

Commit

Permalink
Add failing spec for hashie#69.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelherold authored and dblock committed Aug 24, 2014
1 parent 65dd449 commit 32d5b04
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions spec/hashie/trash_spec.rb
Expand Up @@ -134,6 +134,25 @@ class TrashLambdaTest < Hashie::Trash
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 }
Expand Down

0 comments on commit 32d5b04

Please sign in to comment.