Sha256: f40e5d9222b65a8806ebb91ee8b4dcc38c654e9d10bb33d9f41a1f68d72cd37a

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 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 null: false
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

8 entries across 8 versions & 1 rubygems

Version Path
redstream-0.5.0 spec/spec_helper.rb
redstream-0.4.4 spec/spec_helper.rb
redstream-0.4.3 spec/spec_helper.rb
redstream-0.4.2 spec/spec_helper.rb
redstream-0.4.1 spec/spec_helper.rb
redstream-0.4.0 spec/spec_helper.rb
redstream-0.3.0 spec/spec_helper.rb
redstream-0.2.0 spec/spec_helper.rb