Module: CodeTeams::Testing
- Extended by:
- T::Sig
- Defined in:
- lib/code_teams/testing.rb,
lib/code_teams/testing/rspec_helpers.rb
Overview
Utilities for tests that need a controlled set of teams without writing YML
files to disk.
Opt-in by requiring code_teams/testing.
Defined Under Namespace
Modules: CodeTeamsExtension, RSpecHelpers
Constant Summary
collapse
- THREAD_KEY =
T.let(:__code_teams_collection, Symbol)
Class Method Summary
collapse
Class Method Details
.code_teams ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/code_teams/testing.rb', line 63
def self.code_teams
existing = Thread.current[THREAD_KEY]
return existing if existing.is_a?(Array)
Thread.current[THREAD_KEY] = []
T.cast(Thread.current[THREAD_KEY], T::Array[CodeTeams::Team])
end
|
.create_code_team(attributes) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/code_teams/testing.rb', line 44
def self.create_code_team(attributes)
attributes = attributes.dup
attributes[:name] ||= "Fake Team #{SecureRandom.hex(4)}"
code_team = CodeTeams::Team.new(
config_yml: 'tmp/fake_config.yml',
raw_hash: Utils.deep_stringify_keys(attributes)
)
code_teams << code_team
Plugin.bust_caches!
code_team
end
|
.reset! ⇒ Object
72
73
74
|
# File 'lib/code_teams/testing.rb', line 72
def self.reset!
Thread.current[THREAD_KEY] = []
end
|