Sha256: 878a849eb9ddbae6efd1a88746951ae8237473850429c2091c6422fd7bf8acba

Contents?: true

Size: 920 Bytes

Versions: 11

Compression:

Stored size: 920 Bytes

Contents

require 'helper'

class NestedConfigEvaluateOnceTest < NestedConfigSpec
  let(:config) do
    Class.new(NestedConfig) do
      include NestedConfig::EvaluateOnce
    end.new
  end

  context "evaluates once w/o argument" do
    context "w/o argument" do
      before do
        config.startup_time = proc { Time.now }
      end

      test "has time value" do
        assert_instance_of Time, config.startup_time
      end

      test "value does not change" do
        n = config.startup_time
        assert_same n, config.startup_time
      end
    end

    context "with argument" do
      before do
        config.env = proc { |e| e.to_s.upcase }
        config.env(:development)
      end

      test "replaces original value" do
        assert_equal "DEVELOPMENT", config.env
      end

      test "value does not change" do
        env = config.env
        assert_same env, config.env
      end
    end
  end
end

Version data entries

11 entries across 9 versions & 1 rubygems

Version Path
nested_config-0.6.2 test/nested_config/evaluate_once_test.rb
nested_config-0.6.1 test/nested_config/evaluate_once_test.rb
nested_config-0.6.0 test/nested_config/evaluate_once_test.rb
nested_config-0.5.0 test/nested_config/evaluate_once_test.rb
nested_config-0.4.1 test/nested_config/evaluate_once_test.rb
nested_config-0.4.0 test/nested_config/evaluate_once_test.rb
nested_config-0.3.0 test/nested_config_evaluate_once_test.rb
nested_config-0.2.1 test/nested_config_evaluate_once_test.rb
nested_config-0.2.1 test/neopoly_config_evaluate_once_test.rb
nested_config-0.2.0 test/neopoly_config_evaluate_once_test.rb
nested_config-0.2.0 test/nested_config_evaluate_once_test.rb