Minitest::MatchJson
Compare two JSON objects. If a String is passed in, it is expected to be valid JSON, any other type will be converted to json if possible.
Installation
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
Usage
require 'minitest-match_json'
Diffy is used to compared 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 style
assert_match_json expected_json, actual_json
Spec style
actual_json.must_match_json expected_json
Contributing
- 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