Skip to content

assert_payload tests can become false positives on empty attributes payload and nil json_item #8

Open
@Startouf

Description

@Startouf

I have special payload/serialized result in my app made almost entirely of relationships and no attributes (a conversation = list of messages + references to senders, etc.)

Therefore, my test payload declaration was empty.

In my test, the payload assertion was passing although the return from the controller was nil / the test should have failed

In a nutshell :

# spec/payloads/messaging/conversation.rb
JsonapiSpecHelpers::Payload.register(:'messaging/conversation') do
# empty, only relationships
end

# spec/requests/messaging/conversations_controller.rb
...
json_item = {"id"=>nil, "jsonapi_type"=>nil}
assert_payload(:'messaging/conversation', conversation, json_item)
# Would pass !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions