intridea/grape-entity — pull request #61 by Nerian (2014-03-04 18:20:03+00:00)
Title: minimum test

When https://github.com/intridea/grape-entity/pull/60 was merged I got several errors on my test suite. I have created a minimum failing test that can be run on grape-entity to reproduce the issue:

```ruby
require 'spec_helper'

describe "description" do
it "complex nested attributes" do
class ClassRoom < Grape::Entity
expose(:parents, using: 'Parent') { |_| [{}, {}]}
end

class Person < Grape::Entity
expose :user do
expose(:id) { |_| 'value' }
end
end

class Student < Person
expose :user do
expose(:user_id) { |_| 'value' }
expose(:user_display_id, as: :display_id) { |_| 'value' }
end
end

class Parent < Person
expose(:children, using: 'Student') { |_| [{}, {}]}
end

ClassRoom.represent({}).serializable_hash.should == {
:parents => [
{ :children =>
[
{ user: { user_id: 'value', display_id: 'value' } },
{ user: { user_id: 'value', display_id: 'value' } }
]
}
]
}
end
end
```

This is the error:
````
1) description complex nested attributes
Failure/Error: ClassRoom.represent({}).serializable_hash.should == {
NoMethodError:
undefined method `[]' for nil:NilClass
# ./lib/grape_entity/entity.rb:403:in `key_for'
# ./lib/grape_entity/entity.rb:444:in `block in value_for'
# ./lib/grape_entity/entity.rb:443:in `each'
# ./lib/grape_entity/entity.rb:443:in `map'
# ./lib/grape_entity/entity.rb:443:in `value_for'
# ./lib/grape_entity/entity.rb:366:in `block in serializable_hash'
# ./lib/grape_entity/entity.rb:364:in `each'
# ./lib/grape_entity/entity.rb:364:in `inject'
# ./lib/grape_entity/entity.rb:364:in `serializable_hash'
# ./lib/grape_entity/entity.rb:371:in `block (2 levels) in serializable_hash'
# ./lib/grape_entity/entity.rb:371:in `map'
# ./lib/grape_entity/entity.rb:371:in `block in serializable_hash'
# ./lib/grape_entity/entity.rb:364:in `each'
# ./lib/grape_entity/entity.rb:364:in `inject'
# ./lib/grape_entity/entity.rb:364:in `serializable_hash'
# ./spec/grape_entity/error_spec.rb:26:in `block (2 levels) in '
```