Sha256: aa4c723db8ce881b27c94e39d67a37c9ba4f291f4b0e134ef50724e8afcf02c3

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

module DatabaseRewinder
  describe Cleaner do
    describe '#strategy=' do
      before { @cleaner = described_class.new(only: ['foos'], except: 'bars') }

      context 'without options' do
        before { @cleaner.strategy = :truncation }

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

      context 'with options (an array or a string)' do
        before { @cleaner.strategy = :truncation, { only: ['bars'], except: 'bazs' } }

        it 'should overwrite instance variables' do
          expect(@cleaner.instance_variable_get(:@only)).to eq(['bars'])
          expect(@cleaner.instance_variable_get(:@except)).to eq(['bazs'])
        end
      end

      context 'with options (an empty array or nil)' do
        before { @cleaner.strategy = :truncation, { only: [], except: nil } }

        it 'should overwrite instance variables even if they are empty/nil' do
          expect(@cleaner.instance_variable_get(:@only)).to eq([])
          expect(@cleaner.instance_variable_get(:@except)).to eq([])
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
database_rewinder-0.5.3 spec/cleaner_spec.rb
database_rewinder-0.5.2 spec/cleaner_spec.rb
database_rewinder-0.5.1 spec/cleaner_spec.rb
database_rewinder-0.4.2 spec/cleaner_spec.rb
database_rewinder-0.4.1 spec/cleaner_spec.rb
database_rewinder-0.4.0 spec/cleaner_spec.rb
database_rewinder-0.3.0 spec/cleaner_spec.rb