-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimetravel_integration_test.rb
61 lines (51 loc) · 1.41 KB
/
timetravel_integration_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# frozen_string_literal: true
require 'test_helper'
require 'securerandom'
class TimetravelIntegrationTest < TLDR
def test_ruby_csv_completes
config = ChurnVsComplexity::Timetravel::Config.new(
language: :ruby,
serializer: :csv,
jump_days: 3_000,
relative_period: :month,
factory: FactoryStub.new,
)
config.validate!
result = config.checker.check(folder: ChurnVsComplexity::ROOT_PATH)
refute_nil result
refute_empty result
end
def test_ruby_graph_completes
config = ChurnVsComplexity::Timetravel::Config.new(
language: :ruby,
serializer: :graph,
jump_days: 3_000,
relative_period: :quarter,
factory: FactoryStub.new,
)
config.validate!
result = config.checker.check(folder: ChurnVsComplexity::ROOT_PATH)
refute_nil result
refute_empty result
end
class FactoryStub
F = ChurnVsComplexity::Timetravel::Factory
# Delegate specific methods to F
delegate :git_strategy, :worker, :pipe, to: :F
def initialize
@id = SecureRandom.hex(4)
end
def worktree(**args) = TestWorktree.new(id: @id, **args)
end
class TestWorktree < ChurnVsComplexity::Timetravel::Worktree
def initialize(id:, **args)
super(**args)
@id = id
end
protected
# Dedicated folder for each test, to ensure isolation
def tt_folder
@tt_folder ||= File.join(super, @id)
end
end
end