|
1 | | -RSpec.describe CodeTeams::Plugin do |
2 | | - before do |
3 | | - CodeTeams.bust_caches! |
4 | | - |
5 | | - test_plugin_class = Class.new(described_class) do |
6 | | - def extra_data |
7 | | - @team.raw_hash['extra_data'] |
8 | | - end |
9 | | - end |
10 | | - stub_const('TestPlugin', test_plugin_class) |
11 | | - end |
| 1 | +module TestNamespace; end |
12 | 2 |
|
| 3 | +RSpec.describe CodeTeams::Plugin do |
13 | 4 | describe '.bust_caches!' do |
14 | 5 | it 'clears all plugins team registries ensuring cached configs are purged' do |
| 6 | + test_plugin_class = Class.new(described_class) do |
| 7 | + def extra_data |
| 8 | + @team.raw_hash['extra_data'] |
| 9 | + end |
| 10 | + end |
| 11 | + stub_const('TestNamespace::TestPlugin', test_plugin_class) |
| 12 | + |
| 13 | + CodeTeams.bust_caches! |
15 | 14 | write_team_yml(extra_data: true) |
16 | 15 | team = CodeTeams.find('My Team') |
17 | | - expect(TestPlugin.for(team).extra_data).to be(true) |
| 16 | + expect(TestNamespace::TestPlugin.for(team).extra_data).to be(true) |
18 | 17 | write_team_yml(extra_data: false) |
19 | 18 | CodeTeams.bust_caches! |
20 | 19 | team = CodeTeams.find('My Team') |
21 | | - expect(TestPlugin.for(team).extra_data).to be(false) |
| 20 | + expect(TestNamespace::TestPlugin.for(team).extra_data).to be(false) |
22 | 21 | end |
23 | 22 | end |
24 | 23 |
|
25 | 24 | describe '.data_accessor_name' do |
26 | 25 | it 'returns the underscore version of the plugin name' do |
27 | 26 | test_plugin_class = Class.new(described_class) |
28 | | - stub_const('FooNamespace::TestPlugin', test_plugin_class) |
| 27 | + stub_const('TestNamespace::TestPlugin', test_plugin_class) |
29 | 28 |
|
30 | | - expect(FooNamespace::TestPlugin.data_accessor_name).to eq('test_plugin') |
| 29 | + expect(TestNamespace::TestPlugin.data_accessor_name).to eq('test_plugin') |
31 | 30 | end |
32 | 31 |
|
33 | 32 | it 'can be overridden by a subclass' do |
34 | 33 | test_plugin_class = Class.new(described_class) do |
35 | 34 | data_accessor_name 'foo' |
36 | 35 | end |
37 | | - stub_const('TestPlugin', test_plugin_class) |
| 36 | + stub_const('TestNamespace::TestPlugin', test_plugin_class) |
38 | 37 |
|
39 | | - expect(TestPlugin.data_accessor_name).to eq('foo') |
| 38 | + expect(TestNamespace::TestPlugin.data_accessor_name).to eq('foo') |
40 | 39 | end |
41 | 40 | end |
42 | 41 | end |
0 commit comments