Sha256: 5c6a92689534f743e74c0f59375a95bea162c43f358ff2e4a0a8be2b2372f2af

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'test_helper'

class StatusTest < MiniTest::Unit::TestCase

  def setup
    super
    cache = ActiveSupport::Cache::MemoryStore.new
    ShuntCache::Status.configure do |status|
      status.cache = cache
      status.key = "test_key"
    end
  end

  def teardown
    ShuntCache::Status.configure do |status|
      status.cache = nil
      status.key = nil
    end

    super
  end

  def test_defaults_to_normal
    assert_equal false, ShuntCache::Status.shunted?
    assert_equal ShuntCache::Status::UNSHUNTED, ShuntCache::Status.status
  end

  def test_can_shunt_and_unshunt
    assert_equal false, ShuntCache::Status.shunted?

    # shunt!
    assert ShuntCache::Status.shunt!

    # ensure that we've set the right state
    assert_equal true, ShuntCache::Status.shunted?
    assert_equal ShuntCache::Status::SHUNTED, ShuntCache::Status.status

    # unshunt!
    assert ShuntCache::Status.unshunt!

    # ensure that we've set the right state
    assert_equal false, ShuntCache::Status.shunted?
    assert_equal ShuntCache::Status::UNSHUNTED, ShuntCache::Status.status
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shunt_cache-0.1.0 test/status_test.rb
shunt_cache-0.0.2 test/status_test.rb