Sha256: b88fae9846214ca996f8ad2ea4474b09ba28d982c86eaf7c1692db6051844160

Contents?: true

Size: 1000 Bytes

Versions: 1

Compression:

Stored size: 1000 Bytes

Contents

require "test_helper"

# In general we do not want to expose the inner workings of the caching and unit systems as part of the API.
# But we do want to be able to test that there is no conflict between what's in the cache file and what is defined
# in the unit systems. So we compromise by reaching into implementation to force compare them.
class Measured::CacheConsistencyTest < ActiveSupport::TestCase
  measurable_subclasses.select { |m| m.unit_system.cached? }.each do |measurable|
    test "cached measurable #{ measurable } is not out of sync with the definition" do
      builder = measurable.unit_system.instance_variable_get("@conversion_table_builder")
      cache = builder.instance_variable_get("@cache")

      expected = builder.send(:generate_table)
      actual = cache.read

      assert expected == actual, "The contents of the file cache for `#{ measurable }` does not match what the unit system generated.\nTry running `rake cache:write` to update the caches."
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
measured-2.5.0 test/cache_consistency_test.rb