rspec-snapshot icon indicating copy to clipboard operation
rspec-snapshot copied to clipboard

Allowing to compare the JSON structure only

Open alvesoaj opened this issue 5 years ago • 3 comments

I made this gem allow accept an optional second param on its match

def match_snapshot(snapshot_name, json_structure_only = false)
  MatchSnapShot.new(self.class.metadata, snapshot_name, json_structure_only)
end

it makes the match check only the structure of JSON object to ensure if the actual and expected have the same structure keys and same kind of object on its value.

It is really useful for me, I use Faker to create my tests and with this I don't care with the values itself but just only if my API is getting the same data structure.

I hope it is useful for more people.

alvesoaj avatar Aug 30 '19 15:08 alvesoaj

A good idea is create a new match, to make this stuff clear, instead of have only match_snapshot with an optional param, we can have another match called for example: match_deep_json_snapshot or match_json_structure_snapshot. What do you think guys?

alvesoaj avatar Aug 30 '19 16:08 alvesoaj

Needs rebased

levinmr avatar Jun 21 '21 19:06 levinmr

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Apr 19 '24 19:04 sonarqubecloud[bot]