Compare a JSON string to another JSON object. If a String is passed in, it is expected to be valid JSON, any other type will be converted to json if possible.
Add this line to your application's Gemfile:
gem 'minitest-match_json'
And then execute:
$ bundle
Or install it yourself as:
$ gem install minitest-match_json
require 'minitest-match_json'
Diffy is used to compare the two JSON objects. Options to control the output format and number of context lines to be displayed can be passed through to Diffy.
Minitest::MatchJson.configure do |config|
config.format = :color
config.context = 1
end
assert_match_json expected_json, actual_json
actual_json.must_match_json expected_json
- Fork it ( https://github.com/ggordon/minitest-match_json/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request