-
-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue where Registry fails to resolve first-time lookups on insta…
…nce methods This is due to incorrect cache invalidation in #1260. The fix is to add a callback on NamespaceMapper when invalidation occurs. Also adds tests for RegistryResolver and NamespaceMapper
- Loading branch information
Showing
5 changed files
with
90 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
require File.dirname(__FILE__) + '/spec_helper' | ||
|
||
RSpec.describe YARD::CodeObjects::NamespaceMapper do | ||
include YARD::CodeObjects::NamespaceMapper | ||
|
||
describe '#register_separator' do | ||
it 'should allow separators to be registered' do | ||
register_separator '!', :test_type | ||
|
||
expect(separators_for_type(:test_type)).to eq ['!'] | ||
expect(types_for_separator('!')).to eq [:test_type] | ||
|
||
unregister_separator_by_type :test_type | ||
|
||
expect(separators_for_type(:test_type)).to be_empty | ||
expect(types_for_separator('!')).to be_empty | ||
end | ||
end | ||
|
||
describe '.on_invalidate' do | ||
it 'receives a callback when a new separator is added' do | ||
invalidated = false | ||
NamespaceMapper.on_invalidate { invalidated = true } | ||
|
||
register_separator '!', :test_type | ||
expect(invalidated).to be true | ||
|
||
unregister_separator_by_type :test_type | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe YARD::RegistryResolver do | ||
include YARD::CodeObjects::NamespaceMapper | ||
|
||
describe '#starts_with_separator_match' do | ||
subject { RegistryResolver.new } | ||
|
||
it 'should clear cache when a namespace separator is registered' do | ||
expect(subject.send(:starts_with_separator_match).to_s).not_to include('!') | ||
register_separator '!', :test_type | ||
expect(subject.send(:starts_with_separator_match).to_s).to include('!') | ||
end | ||
end | ||
end |