ruby-changes:74082
From: David <ko1@a...>
Date: Tue, 18 Oct 2022 16:33:40 +0900 (JST)
Subject: [ruby-changes:74082] e956caea88 (master): [rubygems/rubygems] Extract matcher for slow perf spec
https://git.ruby-lang.org/ruby.git/commit/?id=e956caea88 From e956caea88b67cc1a1b42b95327190c63d45888a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Wed, 5 Oct 2022 14:16:57 +0200 Subject: [rubygems/rubygems] Extract matcher for slow perf spec https://github.com/rubygems/rubygems/commit/1c0eb63c6a --- spec/bundler/realworld/slow_perf_spec.rb | 8 +------- spec/bundler/support/matchers.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/spec/bundler/realworld/slow_perf_spec.rb b/spec/bundler/realworld/slow_perf_spec.rb index 9f11821bf5..467e740cb4 100644 --- a/spec/bundler/realworld/slow_perf_spec.rb +++ b/spec/bundler/realworld/slow_perf_spec.rb @@ -11,12 +11,6 @@ RSpec.describe "bundle install with complex dependencies", :realworld => true do https://github.com/ruby/ruby/blob/trunk/spec/bundler/realworld/slow_perf_spec.rb#L11 gem "mongoid", ">= 0.10.2" G - start_time = Time.now - - bundle "lock" - - duration = Time.now - start_time - - expect(duration.to_f).to be < 18 # seconds + expect { bundle "lock" }.to take_less_than(18) # seconds end end diff --git a/spec/bundler/support/matchers.rb b/spec/bundler/support/matchers.rb index ce6b216619..8b22e7dbc3 100644 --- a/spec/bundler/support/matchers.rb +++ b/spec/bundler/support/matchers.rb @@ -97,6 +97,18 @@ module Spec https://github.com/ruby/ruby/blob/trunk/spec/bundler/support/matchers.rb#L97 end end + RSpec::Matchers.define :take_less_than do |seconds| + match do |actual| + start_time = Time.now + + actual.call + + (Time.now - start_time).to_f < seconds + end + + supports_block_expectations + end + define_compound_matcher :read_as, [exist] do |file_contents| diffable -- cgit v1.2.3 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/