DEV: Update test-prof (#7572)

DEV: Update test-prof (#7572)

  • Updated test-prof

  • Made rails_helper.rb use new test-prof APIs

Instead of the previous temporary hacks.

  • Added environment option to disable prefabrication

It was removed mistakenly

diff --git a/Gemfile.lock b/Gemfile.lock
index 81fd8c6..6ae43fe 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -388,7 +388,7 @@ GEM
       sprockets (>= 3.0.0)
     sshkey (2.0.0)
     stackprof (0.2.12)
-    test-prof (0.8.0)
+    test-prof (0.9.0)
     thor (0.20.3)
     thread_safe (0.3.6)
     tilt (2.0.9)
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 6153b9e..3eb1fb2 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -127,37 +127,30 @@ module TestSetup
   end
 end
 
-module ActiveRecordAdapterWithSetup
-  class << self
-    ACTIVE_RECORD_ADAPTER = TestProf::BeforeAll::Adapters::ActiveRecord
-
-    def begin_transaction
-      TestSetup.test_setup
-
-      ACTIVE_RECORD_ADAPTER.begin_transaction
-    end
-
-    def rollback_transaction
-      ACTIVE_RECORD_ADAPTER.rollback_transaction
-    end
+TestProf::BeforeAll.configure do |config|
+  config.before(:begin) do
+    TestSetup.test_setup
   end
 end
 
-TestProf::BeforeAll.adapter = ActiveRecordAdapterWithSetup
-
-module Prefabrication
-  def fab!(name, &blk)
-    if ENV['PREFABRICATION'] == '0'
+if ENV['PREFABRICATION'] == '0'
+  module Prefabrication
+    def fab!(name, &blk)
       let!(name, &blk)
-    else
-      let_it_be(name, refind: true, &blk)
     end
   end
+
+  RSpec.configure do |config|
+    config.extend Prefabrication
+  end
+else
+  TestProf::LetItBe.configure do |config|
+    config.alias_to :fab!, refind: true
+  end
 end
 
 RSpec.configure do |config|
   config.fail_fast = ENV['RSPEC_FAIL_FAST'] == "1"
-  config.extend Prefabrication
   config.include Helpers
   config.include MessageBus
   config.include RSpecHtmlMatchers

GitHub sha: f46d2ad0

1 Like