Skip to content

Commit dd866f9

Browse files
committed
feat: make RSpecHelpers inclusion opt-in
Stop auto-including CodeTeams::RSpecHelpers; clients can include it in their own RSpec config. The testing integration remains opt-in via requiring code_teams/rspec.
1 parent ab35360 commit dd866f9

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

lib/code_teams/rspec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
require 'securerandom'
66
require 'code_teams/testing'
77

8+
CodeTeams::Testing.enable!
9+
810
module CodeTeams
911
module RSpecHelpers
1012
def code_team_with_config(team_config = {})
@@ -17,8 +19,6 @@ def code_team_with_config(team_config = {})
1719

1820
if defined?(RSpec)
1921
RSpec.configure do |config|
20-
config.include CodeTeams::RSpecHelpers
21-
2222
config.around do |example|
2323
example.run
2424
# Bust caches because plugins may hang onto stale data between examples.

lib/code_teams/testing.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ module Testing
1414
extend T::Sig
1515

1616
THREAD_KEY = T.let(:__code_teams_collection, Symbol)
17+
@enabled = T.let(false, T::Boolean)
18+
19+
sig { void }
20+
def self.enable!
21+
return if @enabled
22+
23+
CodeTeams.prepend(CodeTeamsExtension)
24+
@enabled = true
25+
end
1726

1827
sig { params(attributes: T::Hash[T.untyped, T.untyped]).returns(CodeTeams::Team) }
1928
def self.create_code_team(attributes)
@@ -82,5 +91,3 @@ def find(name)
8291
end
8392
end
8493
end
85-
86-
CodeTeams.prepend(CodeTeams::Testing::CodeTeamsExtension)

spec/lib/code_teams/r_spec_helpers_integration_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
require 'code_teams/rspec'
22

33
RSpec.describe CodeTeams::RSpecHelpers do
4+
include described_class
5+
46
it 'exposes code_team_with_config and makes the team discoverable' do
57
code_team_with_config(name: 'RSpec Team')
68

0 commit comments

Comments
 (0)