Skip to content

Comments

Refactor object serializer class methods spec#134

Merged
shishirmk merged 4 commits intoNetflix:devfrom
shuheiktgw:refactor_object_serializer_class_methods_spec
Mar 27, 2018
Merged

Refactor object serializer class methods spec#134
shishirmk merged 4 commits intoNetflix:devfrom
shuheiktgw:refactor_object_serializer_class_methods_spec

Conversation

@shuheiktgw
Copy link
Contributor

@shuheiktgw shuheiktgw commented Mar 22, 2018

I refactored object_serializer_class_methods_spec.rb with subject, let and shared_example since some of the examples seem to be not well organized... Also, I added some missing test cases and fixed seemingly wrong examples!

end

it 'returns correct relationship hash for a belongs_to relationship with overrides' do
MovieSerializer.has_many :area, id_method_name: :blah_id, record_type: :awesome_area, serializer: :my_area
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess has_many was supposed to be belongs_to from the it statement...

MovieSerializer.has_many :roles
relationship = MovieSerializer.relationships_to_serialize[:roles]
expect(relationship).to be_instance_of(Hash)
expect(relationship.keys).to all(be_instance_of(Symbol))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added those Hash and Symbol assertions to every test cases.

relationship = MovieSerializer.relationships_to_serialize[:roles]
expect(relationship).to be_instance_of(Hash)
expect(relationship.keys).to all(be_instance_of(Symbol))
expect(relationship[:id_method_name]).to end_with '_ids'
Copy link
Contributor Author

@shuheiktgw shuheiktgw Mar 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this and one below to assert in more direct way.

@shuheiktgw
Copy link
Contributor Author

shuheiktgw commented Mar 22, 2018

I 'm also thinking about integrating object_serializer_set_id_spec.rb and object_serializer_with_attribute_block_spec.rb to this spec file after this PR is marged!

@shishirmk shishirmk merged commit cdfac87 into Netflix:dev Mar 27, 2018
andyjeffries pushed a commit to andyjeffries/fast_jsonapi that referenced this pull request May 25, 2018
* Add object_serializer_class_methods_examples

* Change to require spec/shared/examples in every spec files

* Refactor object_serializer_class_methods_spec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants