Sha256: 70a92ccdefbcc4d56407f21e2309d3f5dec6ec2c88d1a639b6beb3d568b997b4

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require File.expand_path("../lib/redstream", __dir__)
require "active_record"
require "factory_bot"
require "database_cleaner"
require "timecop"
require "concurrent"
require "mocha"
require "rspec/instafail"

RSpec.configure do |config|
  config.mock_with :mocha
end

ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: "/tmp/redstream.sqlite3")

ActiveRecord::Base.connection.execute "DROP TABLE IF EXISTS products"

ActiveRecord::Base.connection.create_table :products do |t|
  t.string :title
  t.timestamps
end

class Product < ActiveRecord::Base
  include Redstream::Model

  redstream_callbacks

  def redstream_payload
    { id: id }
  end
end

FactoryBot.define do
  factory :product do
    title { "title" }
  end
end

module SpecHelper
  def redis
    @redis ||= Redis.new
  end
end

RSpec.configure do |config|
  config.add_formatter(RSpec::Instafail)
  config.add_formatter(:progress)

  config.include SpecHelper
  config.include FactoryBot::Syntax::Methods

  config.before(:suite) do
    DatabaseCleaner.strategy = :truncation
  end

  config.around do |example|
    DatabaseCleaner.cleaning { example.run }
  end

  config.after do
    Redis.new.flushdb
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redstream-0.1.1 spec/spec_helper.rb
redstream-0.1.0 spec/spec_helper.rb