Skip to content

Commit 83dad59

Browse files
committed
Fix: TimeTravel.freeze to allow non-block when in freeze context + finalize scripting helper
1 parent ad9e037 commit 83dad59

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

spec/support/scripting_helper.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# frozen_string_literal: true
22

33
STUBS_PATH = File.expand_path("../stubs", __FILE__)
4-
PROD_SCRIPTS_PATH = Stoplight::Infrastructure::Redis::Storage::Scripting.default_scripts_path
54

6-
RSpec.configure do |config|
7-
config.before(:each, :redis) do
8-
allow(Stoplight::Infrastructure::Redis::Storage::Scripting)
9-
.to receive(:default_scripts_path)
10-
.and_return([STUBS_PATH, *PROD_SCRIPTS_PATH])
5+
class Stoplight::Infrastructure::Redis::Storage::Scripting
6+
class << self
7+
alias_method :production_default_scripts_path, :default_scripts_path
8+
9+
def default_scripts_path
10+
[STUBS_PATH, *production_default_scripts_path]
11+
end
1112
end
1213
end

spec/support/time_travel.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ def freeze(time = Time.now)
1616
redis.rpop(STACK_KEY)
1717
end
1818
end
19-
else
19+
elsif redis.exists?(STACK_KEY)
2020
redis.del(STACK_KEY)
2121
Timecop.freeze(time)
2222
redis_time_ms = Time.now.to_f * 1000.0
2323
redis.rpush(STACK_KEY, redis_time_ms)
24+
else
25+
raise LocalJumpError, "freeze requires a block"
2426
end
2527
end
2628

0 commit comments

Comments
 (0)