File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11require 'spec_helper'
2- require 'ostruct'
32
43describe RestPack ::Serializer ::Attributes do
54 class CustomSerializer
@@ -8,7 +7,7 @@ class CustomSerializer
87 attributes :d , :e , :f?
98 optional :sometimes , :maybe
109 attribute :old_attribute , :key => :new_key
11- transform [ :gonzaga ] , lambda { |name , model | model . send ( name ) . downcase }
10+ transform [ :gonzaga ] , lambda { |name , model | model [ name ] . downcase }
1211 end
1312
1413 subject ( :attributes ) { CustomSerializer . serializable_attributes }
@@ -34,7 +33,7 @@ class CustomSerializer
3433 end
3534
3635 describe "optional attributes" do
37- let ( :model ) { OpenStruct . new ( a : 'A' , sometimes : 'SOMETIMES' , gonzaga : 'GONZAGA' ) }
36+ let ( :model ) { { a : 'A' , sometimes : 'SOMETIMES' , gonzaga : 'GONZAGA' } }
3837 let ( :context ) { { } }
3938 subject ( :as_json ) { CustomSerializer . as_json ( model , context ) }
4039
@@ -54,7 +53,7 @@ class CustomSerializer
5453 end
5554
5655 describe '#transform_attributes' do
57- let ( :model ) { OpenStruct . new ( gonzaga : 'IS A SCHOOL' ) }
56+ let ( :model ) { { gonzaga : 'IS A SCHOOL' } }
5857
5958 subject ( :as_json ) { CustomSerializer . as_json ( model ) }
6059
You can’t perform that action at this time.
0 commit comments