diff options
author | Rémy Coutable <remy@rymai.me> | 2017-05-04 18:38:34 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-05-04 18:38:34 +0200 |
commit | d263248050ed880349d146e38dd5aef63003ca72 (patch) | |
tree | 2a44f21efb3d762912a752845c78cc4ef00747cb | |
parent | e7b6f39fe1b3d6d21c32f564a3efe17c1c34fd74 (diff) | |
download | gitlab-ce-31836-experimental-knapsack-duration-reporting-tweak.tar.gz |
Monkey-patch Knapsack to include context duration in reports for PG31836-experimental-knapsack-duration-reporting-tweak
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r-- | spec/spec_helper.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e2d5928e5b2..13fcf632f15 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -24,6 +24,40 @@ end if ENV['CI'] && !ENV['NO_KNAPSACK'] require 'knapsack' Knapsack::Adapters::RSpecAdapter.bind + + if ENV['GITLAB_DATABASE'] == 'postgresql' + module Knapsack + module Adapters + class RSpecAdapter < BaseAdapter + def bind_time_tracker + ::RSpec.configure do |config| + config.before(:context) do + Knapsack.tracker.start_timer + end + + config.before(:each) do + current_example_group = + if ::RSpec.respond_to?(:current_example) + ::RSpec.current_example.metadata[:example_group] + else + example.metadata + end + Knapsack.tracker.test_path = RSpecAdapter.test_path(current_example_group) + end + + config.after(:context) do + Knapsack.tracker.stop_timer + end + + config.after(:suite) do + Knapsack.logger.info(Presenter.global_time) + end + end + end + end + end + end + end end # Requires supporting ruby files with custom matchers and macros, etc, |