Sha256: 785baf3143039e597c5b9eb2f0207073f36a57cdc11c3f7030001aade436c306

Contents?: true

Size: 1.73 KB

Versions: 3

Compression:

Stored size: 1.73 KB

Contents

if ENV['TRAVIS']
  # When running in Travis, report coverage stats to Coveralls.
  require 'coveralls'
  Coveralls.wear!
else
  # Otherwise render coverage information in coverage/index.html and display
  # coverage percentage in the console.
  require 'simplecov'
end

require 'rspec/its'
require 'redis'
$LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, '..', '..', 'lib')))
require 'mock_redis'

$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..')))
Dir['spec/support/**/*.rb'].each { |x| require x }

module TypeCheckingHelper
  def method_from_description(example)
    # extracting this from the RSpec description string may or may not
    # be a good idea. On the one hand, it enforces the convention of
    # putting the method name in the right place; on the other hand,
    # it's pretty magic-looking.
    example.full_description.match(/#(\w+)/).captures.first
  end

  def args_for_method(method)
    return [] if method.to_s == 'spop'
    method_arity = @redises.real.method(method).arity
    if method_arity < 0 # -1 comes from def foo(*args)
      [1, 2] # probably good enough
    else
      1.upto(method_arity - 1).to_a
    end
  end
end

RSpec.configure do |config|
  config.expect_with :rspec do |c|
    c.syntax = [:expect, :should]
  end

  config.mock_with :rspec do |c|
    c.syntax = [:expect, :should]
  end

  config.include(TypeCheckingHelper)

  config.before(:all) do
    @redises = RedisMultiplexer.new
  end

  config.before(:each) do
    # databases mentioned in our tests
    [1, 0].each do |db|
      @redises.send_without_checking(:select, db)
      @redises.send_without_checking(:keys, 'mock-redis-test:*').each do |key|
        @redises.send_without_checking(:del, key)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mock_redis-0.19.0 spec/spec_helper.rb
mock_redis-0.18.0 spec/spec_helper.rb
mock_redis-0.17.3 spec/spec_helper.rb