@@ -1039,7 +1039,7 @@ class Parent < Person
10391039 representation = subject . represent ( Array . new ( 4 ) { Object . new } )
10401040 expect ( representation ) . to be_kind_of Array
10411041 expect ( representation . size ) . to eq ( 4 )
1042- expect ( representation . reject { | r | r . is_a? ( subject ) } ) . to be_empty
1042+ expect ( representation . grep_v ( subject ) ) . to be_empty
10431043 end
10441044
10451045 it 'adds the collection: true option if called with a collection' do
@@ -1385,7 +1385,7 @@ class Parent < Person
13851385 expect ( representation ) . to have_key 'things'
13861386 expect ( representation [ 'things' ] ) . to be_kind_of Array
13871387 expect ( representation [ 'things' ] . size ) . to eq 4
1388- expect ( representation [ 'things' ] . reject { | r | r . is_a? ( subject ) } ) . to be_empty
1388+ expect ( representation [ 'things' ] . grep_v ( subject ) ) . to be_empty
13891389 end
13901390 end
13911391
@@ -1394,15 +1394,15 @@ class Parent < Person
13941394 representation = subject . represent ( Array . new ( 4 ) { Object . new } , root : false )
13951395 expect ( representation ) . to be_kind_of Array
13961396 expect ( representation . size ) . to eq 4
1397- expect ( representation . reject { | r | r . is_a? ( subject ) } ) . to be_empty
1397+ expect ( representation . grep_v ( subject ) ) . to be_empty
13981398 end
13991399 it 'can use a different name' do
14001400 representation = subject . represent ( Array . new ( 4 ) { Object . new } , root : 'others' )
14011401 expect ( representation ) . to be_kind_of Hash
14021402 expect ( representation ) . to have_key 'others'
14031403 expect ( representation [ 'others' ] ) . to be_kind_of Array
14041404 expect ( representation [ 'others' ] . size ) . to eq 4
1405- expect ( representation [ 'others' ] . reject { | r | r . is_a? ( subject ) } ) . to be_empty
1405+ expect ( representation [ 'others' ] . grep_v ( subject ) ) . to be_empty
14061406 end
14071407 end
14081408 end
@@ -1426,7 +1426,7 @@ class Parent < Person
14261426 representation = subject . represent ( Array . new ( 4 ) { Object . new } )
14271427 expect ( representation ) . to be_kind_of Array
14281428 expect ( representation . size ) . to eq 4
1429- expect ( representation . reject { | r | r . is_a? ( subject ) } ) . to be_empty
1429+ expect ( representation . grep_v ( subject ) ) . to be_empty
14301430 end
14311431 end
14321432 end
@@ -1449,7 +1449,7 @@ class Parent < Person
14491449 expect ( representation ) . to have_key ( 'things' )
14501450 expect ( representation [ 'things' ] ) . to be_kind_of Array
14511451 expect ( representation [ 'things' ] . size ) . to eq 4
1452- expect ( representation [ 'things' ] . reject { | r | r . is_a? ( subject ) } ) . to be_empty
1452+ expect ( representation [ 'things' ] . grep_v ( subject ) ) . to be_empty
14531453 end
14541454 end
14551455 end
@@ -1474,7 +1474,7 @@ class Parent < Person
14741474 expect ( representation ) . to have_key ( 'things' )
14751475 expect ( representation [ 'things' ] ) . to be_kind_of Array
14761476 expect ( representation [ 'things' ] . size ) . to eq 4
1477- expect ( representation [ 'things' ] . reject { | r | r . is_a? ( child_class ) } ) . to be_empty
1477+ expect ( representation [ 'things' ] . grep_v ( child_class ) ) . to be_empty
14781478 end
14791479 end
14801480 end
@@ -1855,7 +1855,7 @@ def timestamp(date)
18551855
18561856 it 'instantiates a representation if that is called for' do
18571857 rep = subject . value_for ( :friends )
1858- expect ( rep . reject { | r | r . is_a? ( fresh_class ) } ) . to be_empty
1858+ expect ( rep . grep_v ( fresh_class ) ) . to be_empty
18591859 expect ( rep . first . serializable_hash [ :name ] ) . to eq 'Friend 1'
18601860 expect ( rep . last . serializable_hash [ :name ] ) . to eq 'Friend 2'
18611861 end
@@ -1877,7 +1877,7 @@ class FriendEntity < Grape::Entity
18771877
18781878 rep = subject . value_for ( :friends )
18791879 expect ( rep ) . to be_kind_of Array
1880- expect ( rep . reject { | r | r . is_a? ( EntitySpec ::FriendEntity ) } ) . to be_empty
1880+ expect ( rep . grep_v ( EntitySpec ::FriendEntity ) ) . to be_empty
18811881 expect ( rep . first . serializable_hash [ :name ] ) . to eq 'Friend 1'
18821882 expect ( rep . last . serializable_hash [ :name ] ) . to eq 'Friend 2'
18831883 end
@@ -1898,7 +1898,7 @@ class FriendEntity < Grape::Entity
18981898
18991899 rep = subject . value_for ( :custom_friends )
19001900 expect ( rep ) . to be_kind_of Array
1901- expect ( rep . reject { | r | r . is_a? ( EntitySpec ::FriendEntity ) } ) . to be_empty
1901+ expect ( rep . grep_v ( EntitySpec ::FriendEntity ) ) . to be_empty
19021902 expect ( rep . first . serializable_hash ) . to eq ( name : 'Friend 1' , email : 'friend1@example.com' )
19031903 expect ( rep . last . serializable_hash ) . to eq ( name : 'Friend 2' , email : 'friend2@example.com' )
19041904 end
@@ -1956,7 +1956,7 @@ class CharacteristicsEntity < Grape::Entity
19561956
19571957 rep = subject . value_for ( :characteristics )
19581958 expect ( rep ) . to be_kind_of Array
1959- expect ( rep . reject { | r | r . is_a? ( EntitySpec ::CharacteristicsEntity ) } ) . to be_empty
1959+ expect ( rep . grep_v ( EntitySpec ::CharacteristicsEntity ) ) . to be_empty
19601960 expect ( rep . first . serializable_hash [ :key ] ) . to eq 'hair_color'
19611961 expect ( rep . first . serializable_hash [ :value ] ) . to eq 'brown'
19621962 end
@@ -1976,13 +1976,13 @@ class FriendEntity < Grape::Entity
19761976
19771977 rep = subject . value_for ( :friends )
19781978 expect ( rep ) . to be_kind_of Array
1979- expect ( rep . reject { | r | r . is_a? ( EntitySpec ::FriendEntity ) } ) . to be_empty
1979+ expect ( rep . grep_v ( EntitySpec ::FriendEntity ) ) . to be_empty
19801980 expect ( rep . first . serializable_hash [ :email ] ) . to be_nil
19811981 expect ( rep . last . serializable_hash [ :email ] ) . to be_nil
19821982
19831983 rep = subject . value_for ( :friends , Grape ::Entity ::Options . new ( user_type : :admin ) )
19841984 expect ( rep ) . to be_kind_of Array
1985- expect ( rep . reject { | r | r . is_a? ( EntitySpec ::FriendEntity ) } ) . to be_empty
1985+ expect ( rep . grep_v ( EntitySpec ::FriendEntity ) ) . to be_empty
19861986 expect ( rep . first . serializable_hash [ :email ] ) . to eq 'friend1@example.com'
19871987 expect ( rep . last . serializable_hash [ :email ] ) . to eq 'friend2@example.com'
19881988 end
@@ -2002,7 +2002,7 @@ class FriendEntity < Grape::Entity
20022002
20032003 rep = subject . value_for ( :friends , Grape ::Entity ::Options . new ( collection : false ) )
20042004 expect ( rep ) . to be_kind_of Array
2005- expect ( rep . reject { | r | r . is_a? ( EntitySpec ::FriendEntity ) } ) . to be_empty
2005+ expect ( rep . grep_v ( EntitySpec ::FriendEntity ) ) . to be_empty
20062006 expect ( rep . first . serializable_hash [ :email ] ) . to eq 'friend1@example.com'
20072007 expect ( rep . last . serializable_hash [ :email ] ) . to eq 'friend2@example.com'
20082008 end
@@ -2081,7 +2081,7 @@ class UserEntity < Grape::Entity
20812081 rep = subject . value_for ( :friends )
20822082 expect ( rep ) . to be_kind_of Array
20832083 expect ( rep . size ) . to eq 2
2084- expect ( rep . all? { | r | r . is_a? ( EntitySpec ::UserEntity ) } ) . to be true
2084+ expect ( rep . all? ( EntitySpec ::UserEntity ) ) . to be true
20852085 end
20862086
20872087 it 'class' do
@@ -2092,7 +2092,7 @@ class UserEntity < Grape::Entity
20922092 rep = subject . value_for ( :friends )
20932093 expect ( rep ) . to be_kind_of Array
20942094 expect ( rep . size ) . to eq 2
2095- expect ( rep . all? { | r | r . is_a? ( EntitySpec ::UserEntity ) } ) . to be true
2095+ expect ( rep . all? ( EntitySpec ::UserEntity ) ) . to be true
20962096 end
20972097 end
20982098 end
0 commit comments