Sha256: d47b9856b47426d7b0539af829dc9df9377e5cdccfc51e49d1a9ef723a612a97
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true require_relative 'test_helper' require 'mocha/minitest' module Dynflow describe 'flow' do class TestRegistry < Flows::Registry class << self def reset! @serialization_map = {} end end end after do TestRegistry.reset! end describe "registry" do it "allows registering values" do TestRegistry.register!(TestRegistry, 'TS') TestRegistry.register!(Integer, 'I') map = TestRegistry.instance_variable_get("@serialization_map") _(map).must_equal({ 'TS' => TestRegistry, 'I' => Integer }) end it "prevents overwriting values" do TestRegistry.register!(Integer, 'I') _(-> { TestRegistry.register!(Float, 'I') }).must_raise Flows::Registry::IdentifierTaken end it "encodes and decodes values" do TestRegistry.register!(Integer, 'I') _(TestRegistry.encode(Integer)).must_equal 'I' end it "raises an exception when unknown key is requested" do _(-> { TestRegistry.encode(Float) }).must_raise Flows::Registry::UnknownIdentifier _(-> { TestRegistry.decode('F') }).must_raise Flows::Registry::UnknownIdentifier end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dynflow-1.9.0 | test/flows_test.rb |
dynflow-1.8.3 | test/flows_test.rb |