Sha256: 831a90787d448b10ab99b56db951e595c4f1a7e6b77bd869e21184473ae85a3a

Contents?: true

Size: 1.12 KB

Versions: 7

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

7 entries across 7 versions & 1 rubygems

Version Path
database_rewinder-0.9.0 test/cleaner_test.rb
database_rewinder-0.8.3 test/cleaner_test.rb
database_rewinder-0.8.2 test/cleaner_test.rb
database_rewinder-0.8.1 test/cleaner_test.rb
database_rewinder-0.8.0 test/cleaner_test.rb
database_rewinder-0.7.1 test/cleaner_test.rb
database_rewinder-0.7.0 test/cleaner_test.rb