@@ -289,8 +289,7 @@ class Parent < Person
289289 end
290290
291291 additional_hash = { users : [ { id : 1 , name : 'John' } , { id : 2 , name : 'Jay' } ] ,
292- admins : [ { id : 3 , name : 'Jack' } , { id : 4 , name : 'James' } ]
293- }
292+ admins : [ { id : 3 , name : 'Jack' } , { id : 4 , name : 'James' } ] }
294293 expect ( subject . represent ( additional_hash ) . serializable_hash ) . to eq (
295294 profiles : additional_hash [ :users ] + additional_hash [ :admins ] ,
296295 awesome : { just_a_key : 'value' , just_another_key : 'value' }
@@ -354,20 +353,20 @@ class Parent < Person
354353
355354 subject . expose :birthday , format_with : :timestamp
356355
357- model = { birthday : Time . gm ( 2012 , 2 , 27 ) }
356+ model = { birthday : Time . gm ( 2012 , 2 , 27 ) }
358357 expect ( subject . new ( double ( model ) ) . as_json [ :birthday ] ) . to eq '02/27/2012'
359358 end
360359
361360 it 'formats an exposure with a :format_with lambda that returns a value from the entity instance' do
362361 object = { }
363362
364- subject . expose ( :size , format_with : -> ( _value ) { self . object . class . to_s } )
363+ subject . expose ( :size , format_with : -> ( _value ) { object . class . to_s } )
365364 expect ( subject . represent ( object ) . value_for ( :size ) ) . to eq object . class . to_s
366365 end
367366
368367 it 'formats an exposure with a :format_with symbol that returns a value from the entity instance' do
369368 subject . format_with :size_formatter do |_date |
370- self . object . class . to_s
369+ object . class . to_s
371370 end
372371
373372 object = { }
@@ -378,7 +377,7 @@ class Parent < Person
378377
379378 it 'works global on Grape::Entity' do
380379 Grape ::Entity . format_with :size_formatter do |_date |
381- self . object . class . to_s
380+ object . class . to_s
382381 end
383382 object = { }
384383
@@ -609,14 +608,14 @@ class Parent < Person
609608 end
610609
611610 it 'returns multiple entities if called with a collection' do
612- representation = subject . represent ( 4 . times . map { Object . new } )
611+ representation = subject . represent ( Array . new ( 4 ) { Object . new } )
613612 expect ( representation ) . to be_kind_of Array
614613 expect ( representation . size ) . to eq ( 4 )
615614 expect ( representation . reject { |r | r . is_a? ( subject ) } ) . to be_empty
616615 end
617616
618617 it 'adds the collection: true option if called with a collection' do
619- representation = subject . represent ( 4 . times . map { Object . new } )
618+ representation = subject . represent ( Array . new ( 4 ) { Object . new } )
620619 representation . each { |r | expect ( r . options [ :collection ] ) . to be true }
621620 end
622621
@@ -628,7 +627,7 @@ class Parent < Person
628627
629628 it 'returns a serialized array of hashes of multiple objects if serializable: true' do
630629 subject . expose ( :awesome ) { |_ | true }
631- representation = subject . represent ( 2 . times . map { Object . new } , serializable : true )
630+ representation = subject . represent ( Array . new ( 2 ) { Object . new } , serializable : true )
632631 expect ( representation ) . to eq ( [ { awesome : true } , { awesome : true } ] )
633632 end
634633
@@ -903,7 +902,7 @@ class Parent < Person
903902 subject . present_collection true
904903 subject . expose :items
905904
906- representation = subject . represent ( 4 . times . map { Object . new } )
905+ representation = subject . represent ( Array . new ( 4 ) { Object . new } )
907906 expect ( representation ) . to be_kind_of ( subject )
908907 expect ( representation . object ) . to be_kind_of ( Hash )
909908 expect ( representation . object ) . to have_key :items
@@ -915,7 +914,7 @@ class Parent < Person
915914 subject . present_collection true , :my_items
916915 subject . expose :my_items
917916
918- representation = subject . represent ( 4 . times . map { Object . new } , serializable : true )
917+ representation = subject . represent ( Array . new ( 4 ) { Object . new } , serializable : true )
919918 expect ( representation ) . to be_kind_of ( Grape ::Entity ::Exposure ::NestingExposure ::OutputBuilder )
920919 expect ( representation ) . to be_kind_of ( Hash )
921920 expect ( representation ) . to have_key :my_items
@@ -941,7 +940,7 @@ class Parent < Person
941940
942941 context 'with an array of objects' do
943942 it 'allows a root element name to be specified' do
944- representation = subject . represent ( 4 . times . map { Object . new } )
943+ representation = subject . represent ( Array . new ( 4 ) { Object . new } )
945944 expect ( representation ) . to be_kind_of Hash
946945 expect ( representation ) . to have_key 'things'
947946 expect ( representation [ 'things' ] ) . to be_kind_of Array
@@ -952,13 +951,13 @@ class Parent < Person
952951
953952 context 'it can be overridden' do
954953 it 'can be disabled' do
955- representation = subject . represent ( 4 . times . map { Object . new } , root : false )
954+ representation = subject . represent ( Array . new ( 4 ) { Object . new } , root : false )
956955 expect ( representation ) . to be_kind_of Array
957956 expect ( representation . size ) . to eq 4
958957 expect ( representation . reject { |r | r . is_a? ( subject ) } ) . to be_empty
959958 end
960959 it 'can use a different name' do
961- representation = subject . represent ( 4 . times . map { Object . new } , root : 'others' )
960+ representation = subject . represent ( Array . new ( 4 ) { Object . new } , root : 'others' )
962961 expect ( representation ) . to be_kind_of Hash
963962 expect ( representation ) . to have_key 'others'
964963 expect ( representation [ 'others' ] ) . to be_kind_of Array
@@ -984,7 +983,7 @@ class Parent < Person
984983
985984 context 'with an array of objects' do
986985 it 'allows a root element name to be specified' do
987- representation = subject . represent ( 4 . times . map { Object . new } )
986+ representation = subject . represent ( Array . new ( 4 ) { Object . new } )
988987 expect ( representation ) . to be_kind_of Array
989988 expect ( representation . size ) . to eq 4
990989 expect ( representation . reject { |r | r . is_a? ( subject ) } ) . to be_empty
@@ -1005,7 +1004,7 @@ class Parent < Person
10051004
10061005 context 'with an array of objects' do
10071006 it 'allows a root element name to be specified' do
1008- representation = subject . represent ( 4 . times . map { Object . new } )
1007+ representation = subject . represent ( Array . new ( 4 ) { Object . new } )
10091008 expect ( representation ) . to be_kind_of Hash
10101009 expect ( representation ) . to have_key ( 'things' )
10111010 expect ( representation [ 'things' ] ) . to be_kind_of Array
@@ -1030,7 +1029,7 @@ class Parent < Person
10301029
10311030 it 'inherits array root root' do
10321031 child_class = Class . new ( subject )
1033- representation = child_class . represent ( 4 . times . map { Object . new } )
1032+ representation = child_class . represent ( Array . new ( 4 ) { Object . new } )
10341033 expect ( representation ) . to be_kind_of Hash
10351034 expect ( representation ) . to have_key ( 'things' )
10361035 expect ( representation [ 'things' ] ) . to be_kind_of Array
0 commit comments