Sha256: 5587a60286dfc222930ac254425529cb0c8093b4f29d3f2a76660a9d6132715a

Contents?: true

Size: 687 Bytes

Versions: 2

Compression:

Stored size: 687 Bytes

Contents

class MiniTest::Test
  def teardown
    Redis.new.flushdb
    Dalli::Client.new.flush
    CachedRecord::Cache.clear!
  end
end

module MiniTest::Assertions
  def assert_equal_hashes exp, act, msg = nil
    msg = message(msg, "") { diff exp, act }
    exp = JSON.parse(exp.gsub(/@\d+$/, "")) if exp.is_a?(String)
    act = JSON.parse(act.gsub(/@\d+$/, "")) if act.is_a?(String)
    assert(recursive_symbolize_keys(exp) == recursive_symbolize_keys(act), msg)
  end
private
  def recursive_symbolize_keys(hash)
    return unless hash
    hash.inject({}) do |hash, (key, value)|
      hash[key.to_sym] = value.is_a?(Hash) ? recursive_symbolize_keys(hash) : value
      hash
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cached_record-0.1.1 test/test_helper/minitest.rb
cached_record-0.1.0 test/test_helper/minitest.rb