Sha256: 058fd634109dbebb056e28d297f62b23e8b4b1bb5e64ea09444cc4dc8ffd17cf

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

$TESTING = true
require 'rubygems'
# require 'simplecov'
# SimpleCov.start
require 'minitest/pride' unless RUBY_ENGINE == 'rbx'
require 'minitest/autorun'
require 'mocha/setup'
require 'memcached_mock'

ENV['MEMCACHED_SASL_PWDB'] = "#{File.dirname(__FILE__)}/sasl/sasldb"
ENV['SASL_CONF_PATH'] = "#{File.dirname(__FILE__)}/sasl/memcached.conf"

WANT_RAILS_VERSION = ENV['RAILS_VERSION'] || '>= 3.0.0'
gem 'rails', WANT_RAILS_VERSION
require 'rails'
puts "Testing with Rails #{Rails.version}"

require 'dalli'
require 'logger'

Dalli.logger = Logger.new(STDOUT)
Dalli.logger.level = Logger::ERROR

class MiniTest::Spec
  include MemcachedMock::Helper

  def assert_error(error, regexp=nil, &block)
    ex = assert_raises(error, &block)
    assert_match(regexp, ex.message, "#{ex.class.name}: #{ex.message}\n#{ex.backtrace.join("\n\t")}")
  end

  def op_cas_succeeds(rsp)
    rsp.is_a?(Integer) && rsp > 0
  end

  def op_replace_succeeds(rsp)
    rsp.is_a?(Integer) && rsp > 0
  end

  # add and set must have the same return value because of DalliStore#write_entry
  def op_addset_succeeds(rsp)
    rsp.is_a?(Integer) && rsp > 0
  end

  def with_activesupport
    require 'active_support/all'
    require 'active_support/cache/dalli_store'
    yield
  end

  def with_actionpack
    require 'action_dispatch'
    require 'action_controller'
    yield
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dalli-2.7.4 test/helper.rb
dalli-2.7.3 test/helper.rb