Sha256: 34b2f4791871c8b66d7e90b5876524ceb997111247fca0935541f0b10878d49b

Contents?: true

Size: 1.12 KB

Versions: 11

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

require 'test_helper'

class DatabaseRewinder::CleanerTest < ActiveSupport::TestCase
  sub_test_case '#strategy=' do
    setup { @cleaner = DatabaseRewinder::Cleaner.new(only: ['foos'], except: 'bars') }

    test 'without options' do
      @cleaner.strategy = :truncation

      # it should keep instance variables
      assert_equal ['foos'], @cleaner.instance_variable_get(:@only)
      assert_equal ['bars'], @cleaner.instance_variable_get(:@except)
    end

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

      # it should overwrite instance variables
      assert_equal ['bars'], @cleaner.instance_variable_get(:@only)
      assert_equal ['bazs'], @cleaner.instance_variable_get(:@except)
    end

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

      # it should overwrite instance variables even if they are empty/nil
      assert_equal [], @cleaner.instance_variable_get(:@only)
      assert_equal [], @cleaner.instance_variable_get(:@except)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
database_rewinder-1.0.1 test/cleaner_test.rb
database_rewinder-1.0.0 test/cleaner_test.rb
database_rewinder-0.9.9 test/cleaner_test.rb
database_rewinder-0.9.8 test/cleaner_test.rb
database_rewinder-0.9.7 test/cleaner_test.rb
database_rewinder-0.9.6 test/cleaner_test.rb
database_rewinder-0.9.5 test/cleaner_test.rb
database_rewinder-0.9.4 test/cleaner_test.rb
database_rewinder-0.9.3 test/cleaner_test.rb
database_rewinder-0.9.2 test/cleaner_test.rb
database_rewinder-0.9.1 test/cleaner_test.rb