From f46d2ad0866ef0b7814d478e07f0111747ca0150 Mon Sep 17 00:00:00 2001 From: Daniel Waterworth Date: Tue, 21 May 2019 12:07:40 +0000 Subject: [PATCH] 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 --- Gemfile.lock | 2 +- spec/rails_helper.rb | 35 ++++++++++++++--------------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 81fd8c60630..6ae43fe2785 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 6153b9e0f1e..3eb1fb20c03 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