Sha256: c5211b9328a3752c589f9000cc6cba4aae03c662b3bd3de8222bc81d66133be2

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

module DatabaseRewinder
  describe Cleaner do
    describe '#strategy=' do
      before { @cleaner = described_class.new }

      context 'when only strategy is given' do
        before { @cleaner.strategy = :truncation }

        it 'should ignore strategy' do
          expect(@cleaner.instance_variable_get(:@only)).to eq([])
          expect(@cleaner.instance_variable_get(:@except)).to eq([])
        end
      end

      context 'when only option is given' do
        before { @cleaner.strategy = :truncation, { only: ['foos'] } }

        it 'should set only option' do
          expect(@cleaner.instance_variable_get(:@only)).to eq(['foos'])
          expect(@cleaner.instance_variable_get(:@except)).to eq([])
        end
      end

      context 'when except option is given' do
        before { @cleaner.strategy = :truncation, { except: ['foos'] } }

        it 'should set only option' do
          expect(@cleaner.instance_variable_get(:@only)).to eq([])
          expect(@cleaner.instance_variable_get(:@except)).to eq(['foos'])
        end
      end

      context 'when only and except option are given' do
        before { @cleaner.strategy = :truncation, { only: ['foos'], except: ['bars'] } }

        it 'should set only option' do
          expect(@cleaner.instance_variable_get(:@only)).to eq(['foos'])
          expect(@cleaner.instance_variable_get(:@except)).to eq(['bars'])
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
database_rewinder-0.2.0 spec/cleaner_spec.rb
database_rewinder-0.1.0 spec/cleaner_spec.rb
database_rewinder-0.0.3 spec/cleaner_spec.rb