Sha256: 8f7e9a0d164f7c5b2200a4173fd625cb380d6553426d9e5779fcaf74bd049d6a

Contents?: true

Size: 862 Bytes

Versions: 7

Compression:

Stored size: 862 Bytes

Contents

require "test_helper"

class CacheKeeper::CachedMethod::SerializableTargetTest < ActiveSupport::TestCase
  test "#serialize_target doesn't allow unknown serializers" do
    recording = Recording.new(number: 5)
    cached_method = CacheKeeper::CachedMethod.new(Recording, :another_method, serializer: :unknown_serializer)

    error = assert_raises RuntimeError do
      cached_method.serialize_target(recording)
    end

    assert_includes error.message, "Unknown serializer: unknown_serializer"
  end

  test "#serialize_target raises an error if unable to serialize" do
    cached_method = CacheKeeper::CachedMethod.new(Recording, :another_method, serializer: :marshal)

    error = assert_raises RuntimeError do
      cached_method.serialize_target(Proc.new {})
    end

    assert_includes error.message, "Error serializing target using marshal:"
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cache_keeper-0.6.1 test/models/cached_method/serializable_target_test.rb
cache_keeper-0.6.0 test/models/cached_method/serializable_target_test.rb
cache_keeper-0.5.1 test/models/cached_method/serializable_target_test.rb
cache_keeper-0.5.0 test/models/cached_method/serializable_target_test.rb
cache_keeper-0.4.1 test/models/cached_method/serializable_target_test.rb
cache_keeper-0.4.0 test/models/cached_method/serializable_target_test.rb
cache_keeper-0.3.0 test/models/cached_method/serializable_target_test.rb