Sha256: 048a2e935adb6f7148899f3a736dd0c4cdc849af4cf6631e6013f86e102d47c2

Contents?: true

Size: 708 Bytes

Versions: 6

Compression:

Stored size: 708 Bytes

Contents

require "test_helper"

class ModeSwitchingTestCase < ActiveSupport::TestCase
  self.use_transactional_tests = false

  def self.test_data_mode(mode)
    if mode == :factory_bot
      require "factory_bot_rails"
      include FactoryBot::Syntax::Methods

      setup do
        TestData.uses_clean_slate
      end
    elsif mode == :test_data
      setup do
        TestData.uses_test_data
      end
    end
  end
end

class FactoryModeTest < ModeSwitchingTestCase
  test_data_mode :factory_bot

  def test_boops
    create(:boop)

    assert_equal 1, Boop.count
  end
end

class TestDataModeTest < ModeSwitchingTestCase
  test_data_mode :test_data

  def test_boops
    assert_equal 10, Boop.count
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
test_data-0.3.2 example/test/integration/mode_switching_demo_test.rb
test_data-0.3.1 example/test/integration/mode_switching_demo_test.rb
test_data-0.3.0 example/test/integration/mode_switching_demo_test.rb
test_data-0.2.2 example/test/integration/mode_switching_demo_test.rb
test_data-0.2.1 example/test/integration/mode_switching_demo_test.rb
test_data-0.2.0 example/test/integration/mode_switching_demo_test.rb