Skip to content

ggordon/minitest-match_json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minitest::MatchJson

Build Status Gem Version Code Climate Test Coverage

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.

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 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 style

assert_match_json expected_json, actual_json

Spec style

actual_json.must_match_json expected_json

Contributing

  1. Fork it ( https://github.com/ggordon/minitest-match_json/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Minitest comparer for JSON objects

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages