|
204 | 204 | :name => 'Bob Bobson', |
205 | 205 | |
206 | 206 | :birthday => Time.new(2012, 2, 27), |
| 207 | + :fantasies => ['Unicorns', 'Double Rainbows', 'Nessy'], |
207 | 208 | :friends => [ |
208 | | - mock(:name => "Friend 1", :email => '[email protected]', :birthday => Time.new(2012, 2, 27), :friends => []), |
209 | | - mock(:name => "Friend 2", :email => '[email protected]', :birthday => Time.new(2012, 2, 27), :friends => []) |
| 209 | + mock(:name => "Friend 1", :email => '[email protected]', :fantasies => [], :birthday => Time.new(2012, 2, 27), :friends => []), |
| 210 | + mock(:name => "Friend 2", :email => '[email protected]', :fantasies => [], :birthday => Time.new(2012, 2, 27), :friends => []) |
210 | 211 | ] |
211 | 212 | } } |
212 | 213 | subject{ fresh_class.new(model) } |
|
236 | 237 | def timestamp(date) |
237 | 238 | date.strftime('%m/%d/%Y') |
238 | 239 | end |
| 240 | + |
| 241 | + expose :fantasies, :format_with => lambda {|f| f.reverse } |
239 | 242 | end |
240 | 243 | end |
241 | 244 |
|
@@ -272,6 +275,10 @@ class FriendEntity < Grape::Entity |
272 | 275 | it 'should return a formatted value if format_with is passed' do |
273 | 276 | subject.send(:value_for, :birthday).should == '02/27/2012' |
274 | 277 | end |
| 278 | + |
| 279 | + it 'should return a formatted value if format_with is passed a lambda' do |
| 280 | + subject.send(:value_for, :fantasies).should == ['Nessy', 'Double Rainbows', 'Unicorns'] |
| 281 | + end |
275 | 282 | end |
276 | 283 |
|
277 | 284 | describe '#key_for' do |
|
0 commit comments