Skip to content

JsonSpec.remember does not properly verify input #90

@fireyone29

Description

@fireyone29

The code in JsonSpec.remember assumes that the incoming argument will be a string and uses the % operator to interpolate from the memory hash into the string. However, it is perfectly possible to pass in a Numeric type (e.g. Fixnum) for which the % operator means something totally different which causes the code to try to convert the hash to fixnum, which it can't. This is especially problematic from the cucumber matchers, where your input is always run through remember.

I ran into the problem when trying to do a cucumber step like "And the JSON at "count" should be 10" but I am completely unable to reproduce it in this repo's cucumber tests (the 10 always comes in as a string some way I don't understand).

It appears possible to fix this either by doing .to_s on the income argument or changing the exclusion criteria to also include .is_a?(Numeric) (i.e. in addition to checking if the memory hash is empty). I think the is numeric check is more precise, so I'll submit a pull request with that change, but both solve my particular problem.

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