Sha256: 45e1b7845c865c9961fb8af4666ce675ade855a5ade7990c47347419adc5279c

Contents?: true

Size: 989 Bytes

Versions: 14

Compression:

Stored size: 989 Bytes

Contents

RSpec.shared_context 'accounts' do
  let(:accounts) { container.relations[:accounts] }
  let(:cards) { container.relations[:cards] }

  before do
    inferrable_relations.concat %i(accounts cards subscriptions)
  end

  before do |example|
    ctx = self

    conn.create_table :accounts do
      primary_key :id
      Integer :user_id
      String :number

      if ctx.oracle?(example)
        Number :balance
      else
        Decimal :balance, size: [10, 2]
      end
    end

    conn.create_table :cards do
      primary_key :id
      Integer :account_id
      String :pan
    end

    conn.create_table :subscriptions do
      primary_key :id
      Integer :card_id
      String :service
    end
  end

  before do |example|
    next if example.metadata[:seeds] == false

    conn[:accounts].insert user_id: 1, number: '42', balance: 10_000.to_d
    conn[:cards].insert id: 1, account_id: 1, pan: '*6789'
    conn[:subscriptions].insert id: 1, card_id: 1, service: 'aws'
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rom-sql-1.3.5 spec/shared/accounts.rb
rom-sql-1.3.4 spec/shared/accounts.rb
rom-sql-1.3.3 spec/shared/accounts.rb
rom-sql-1.3.2 spec/shared/accounts.rb
rom-sql-1.3.1 spec/shared/accounts.rb
rom-sql-1.3.0 spec/shared/accounts.rb
rom-sql-1.2.2 spec/shared/accounts.rb
rom-sql-1.2.1 spec/shared/accounts.rb
rom-sql-1.2.0 spec/shared/accounts.rb
rom-sql-1.1.2 spec/shared/accounts.rb
rom-sql-1.1.1 spec/shared/accounts.rb
rom-sql-1.1.0 spec/shared/accounts.rb
rom-sql-1.0.3 spec/shared/accounts.rb
rom-sql-1.0.2 spec/shared/accounts.rb