Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Layer#component_defined? method #133

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/rggen/core/builder/layer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def shared_context(&body)
current_shared_context(false)
end

def component_defined?(component_name)
@feature_registries.key?(component_name)
end

def define_feature(feature_names, &body)
Array(feature_names).each do |feature_name|
do_proxy_call(__method__, nil, feature_name, &body)
Expand Down
10 changes: 10 additions & 0 deletions spec/rggen/core/builder/layer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
layer.add_feature_registry(:buzz, buzz_feature_registry)
end

describe '#component_defined?' do
it '指定したコンポーネントが定義済みかどうかを返す' do
expect(layer.component_defined?(:fizz)).to eq true
expect(layer.component_defined?(:buzz)).to eq true
expect(layer.component_defined?(:foo)).to eq false
expect(layer.component_defined?(:bar)).to eq false

end
end

describe 'フィーチャーの定義' do
specify '#add_feature_registry呼び出し時に指定した登録名でフィーチャーを定義できる' do
expect(fizz_feature_registry).to receive(:define_feature).with(:foo_0).and_call_original
Expand Down