Sha256: 61d7c39124597db3718329a739aba84bdb98ee3198bdbd33382a468316255462
Contents?: true
Size: 615 Bytes
Versions: 1
Compression:
Stored size: 615 Bytes
Contents
require 'helper' $called = 0 class SomeModel < OpenStruct extend LazyModelConst lazy_model_const :IMPORTANT_INSTANCE, name: "imp", desc: "Really really important" def self.find_or_create_by_name(attrs = {}) $called += 1 new(attrs) end end class TestLazyModelConst < MiniTest::Unit::TestCase def test_lazy_model_const assert_equal $called, 0 instance = SomeModel.IMPORTANT_INSTANCE assert_equal $called, 1 assert_equal instance, SomeModel.IMPORTANT_INSTANCE assert_equal $called, 1 assert_equal instance, SomeModel.IMPORTANT_INSTANCE assert_equal $called, 1 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lazy_model_const-0.1.1 | test/test_lazy_model_const.rb |