Minitest::ExtendedAssertions
Extended assertions for Minitest
Installation
Add this line to your application's Gemfile:
gem 'minitest-extended_assertions'
And then execute:
$ bundle
Or install it yourself as:
$ gem install minitest-extended_assertions
Usage
Add in minitest_helper
require 'minitest/extended_assertions'
Hash
expected = {a: 1, b: 2}
actual = {a: 2, b: 1}
assert_equal_hash expected, actual
actual.must_equal_hash expected
# [:a]
# Expected: 1
# Actual: 2
# [:b]
# Expected: 2
# Actual: 1
Array
expected = [1, 2, 3, 4]
actual = [1, 20, 3, 40]
assert_equal_array expected, actual
actual.must_equal_array expected
# [1]
# Expected: 2
# Actual: 20
# [3]
# Expected: 4
# Actual: 40
JSON
expected = '{"a": 1, "b": 2}'
actual = '{"a": 2, "b": 1}'
assert_equal_json expected, actual
actual.must_equal_json expected
# ["a"]
# Expected: 1
# Actual: 2
# ["b"]
# Expected: 2
# Actual: 1
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/gabynaiman/minitest-extended_assertions.
License
The gem is available as open source under the terms of the MIT License.