diff options
Diffstat (limited to 'spec/hashie/trash_spec.rb')
-rw-r--r-- | spec/hashie/trash_spec.rb | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/spec/hashie/trash_spec.rb b/spec/hashie/trash_spec.rb index f63790a..4bf4e45 100644 --- a/spec/hashie/trash_spec.rb +++ b/spec/hashie/trash_spec.rb @@ -35,24 +35,23 @@ describe Hashie::Trash do it 'maintains inverse translations hash mapping from the translated to the original name' do TrashTest.inverse_translations[:first_name].should eq :firstName end - end - describe 'permitted input keys' do - class TrashTest < Hashie::Trash - property :id + it '#permitted_input_keys contain the :from key of properties with translations' do + TrashTest.permitted_input_keys.should include :firstName end + end - it 'contain names of properties without translations' do - TrashTest.permitted_input_keys.should include :id + describe 'standard properties' do + class TrashTestPermitted < Hashie::Trash + property :id end - it 'contain the :from key of properties with translations' do - TrashTest.permitted_input_keys.should include :firstName + it '#permitted_input_keys contain names of properties without translations' do + TrashTestPermitted.permitted_input_keys.should include :id end end describe 'writing to properties' do - it 'does not write to a non-existent property using []=' do lambda { trash['abc'] = 123 }.should raise_error(NoMethodError) end @@ -113,20 +112,20 @@ describe Hashie::Trash do let(:lambda_trash) { TrashLambdaTest.new } - it 'should translate the value given on initialization with the given lambda' do + it 'translates the value given on initialization with the given lambda' do TrashLambdaTest.new(firstName: 'Michael').first_name.should eq 'Michael'.reverse end - it 'should not translate the value if given with the right property' do + it 'does not translate the value if given with the right property' do TrashTest.new(first_name: 'Michael').first_name.should eq 'Michael' end - it 'should translate the value given as property with the given lambda' do + it 'translates the value given as property with the given lambda' do lambda_trash.firstName = 'Michael' lambda_trash.first_name.should eq 'Michael'.reverse end - it 'should not translate the value given as right property' do + it 'does not translate the value given as right property' do lambda_trash.first_name = 'Michael' lambda_trash.first_name.should eq 'Michael' end @@ -157,12 +156,12 @@ describe Hashie::Trash do let(:lambda_trash) { TrashLambdaTestWithProperties.new } - it 'should translate the value given as property with the given lambda' do + it 'translates the value given as property with the given lambda' do lambda_trash.first_name = 'Michael' lambda_trash.first_name.should eq 'Michael'.reverse end - it 'should transform the value when given in constructor' do + it 'transforms the value when given in constructor' do TrashLambdaTestWithProperties.new(first_name: 'Michael').first_name.should eq 'Michael'.reverse end @@ -171,11 +170,11 @@ describe Hashie::Trash do property :first_name, from: :firstName, transform_with: lambda { |value| value.reverse } end - it 'should not override the :from option in the constructor' do + it 'does not override the :from option in the constructor' do TrashLambdaTest3.new(first_name: 'Michael').first_name.should eq 'Michael' end - it 'should not override the :from option when given as property' do + it 'does not override the :from option when given as property' do t = TrashLambdaTest3.new t.first_name = 'Michael' t.first_name.should eq 'Michael' @@ -184,7 +183,7 @@ describe Hashie::Trash do end end - it 'should raise an error when :from have the same value as property' do + it 'raises an error when :from have the same value as property' do expect do class WrongTrash < Hashie::Trash property :first_name, from: :first_name |