Sha256: 24e415ff7fd1cf435ff7d0b1c04e0437f2c3b34a0b5b2aff4db300d9b031965e

Contents?: true

Size: 1.36 KB

Versions: 25

Compression:

Stored size: 1.36 KB

Contents

require 'helper'
require 'flipper/adapters/active_record'
require 'flipper/spec/shared_adapter_specs'

# Turn off migration logging for specs
ActiveRecord::Migration.verbose = false

RSpec.describe Flipper::Adapters::ActiveRecord do
  subject { described_class.new }

  before(:all) do
    ActiveRecord::Base.establish_connection(adapter: 'sqlite3',
                                            database: ':memory:')
  end

  before(:each) do
    ActiveRecord::Base.connection.execute <<-SQL
      CREATE TABLE flipper_features (
        id integer PRIMARY KEY,
        key text NOT NULL UNIQUE,
        created_at datetime NOT NULL,
        updated_at datetime NOT NULL
      )
    SQL

    ActiveRecord::Base.connection.execute <<-SQL
      CREATE TABLE flipper_gates (
        id integer PRIMARY KEY,
        feature_key text NOT NULL,
        key text NOT NULL,
        value text DEFAULT NULL,
        created_at datetime NOT NULL,
        updated_at datetime NOT NULL
      )
    SQL

    ActiveRecord::Base.connection.execute <<-SQL
      CREATE UNIQUE INDEX index_gates_on_keys_and_value on flipper_gates (feature_key, key, value)
    SQL
  end

  after(:each) do
    ActiveRecord::Base.connection.execute("DROP table IF EXISTS `flipper_features`")
    ActiveRecord::Base.connection.execute("DROP table IF EXISTS `flipper_gates`")
  end

  it_should_behave_like 'a flipper adapter'
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
flipper-active_record-0.20.4 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.20.3 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.20.2 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.20.1 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.20.0 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.20.0.beta3 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.20.0.beta2 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.20.0.beta1 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.19.1 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.19.0 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.18.0 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.17.2 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.17.1 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.16.2 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.16.1 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.16.0 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.15.0 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.14.0 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.13.0 spec/flipper/adapters/active_record_spec.rb
flipper-active_record-0.13.0.beta1 spec/flipper/adapters/active_record_spec.rb