diff --git a/lib/rggen/core/dsl.rb b/lib/rggen/core/dsl.rb index 05aa8cc..1a9e5ab 100644 --- a/lib/rggen/core/dsl.rb +++ b/lib/rggen/core/dsl.rb @@ -27,7 +27,7 @@ module DSL :enable_all, :delete, :setup_plugin, - :update_plugin, + :update_plugin ].each do |method_name| def_delegator :'RgGen.builder', method_name end diff --git a/lib/rggen/core/input_base/component_factory.rb b/lib/rggen/core/input_base/component_factory.rb index e7412cb..21b3b7e 100644 --- a/lib/rggen/core/input_base/component_factory.rb +++ b/lib/rggen/core/input_base/component_factory.rb @@ -55,19 +55,20 @@ def create_input_data(*_args, &) end def create_features(component, *sources) - create_active_features(component, sources.last) - create_passive_features(component) + create_active_features(component, sources) + create_passive_features(component, sources) end - def create_active_features(component, input_data) + def create_active_features(component, sources) active_feature_factories.each do |name, factory| - create_feature(component, factory, input_data[name]) + input_data = sources.last[name] + create_feature(component, factory, *sources[0..-2], input_data) end end - def create_passive_features(component) + def create_passive_features(component, sources) passive_feature_factories.each_value do |factory| - create_feature(component, factory) + create_feature(component, factory, *sources[0..-2]) end end diff --git a/spec/rggen/core/input_base/component_factory_spec.rb b/spec/rggen/core/input_base/component_factory_spec.rb index 1dbe663..5032600 100644 --- a/spec/rggen/core/input_base/component_factory_spec.rb +++ b/spec/rggen/core/input_base/component_factory_spec.rb @@ -97,16 +97,41 @@ def find_child_factory(*args) describe 'フィーチャーの生成' do describe '能動フィーチャーの生成' do - it '生成したコンポーネントと、引数の末尾から取り出した入力値を引数として、能動フィーチャーを生成する' do - expect(foo_feature_factories[:foo_0]).to receive(:create).with(equal(component), equal(input_data[:foo_0])).and_call_original - expect(foo_feature_factories[:foo_1]).to receive(:create).with(equal(component), equal(input_data[:foo_1])).and_call_original + it '生成したコンポーネントと、引数の末尾を入力値として、能動フィーチャーを生成する' do + expect(foo_feature_factories[:foo_0]) + .to receive(:create) + .with(equal(component), equal(input_data[:foo_0])) + .and_call_original + expect(foo_feature_factories[:foo_1]) + .to receive(:create) + .with(equal(component), equal(input_data[:foo_1])) + .and_call_original + foo_factory.create(parent, input_data) + + expect(foo_feature_factories[:foo_0]) + .to receive(:create) + .with(equal(component), equal(other_input_data), equal(input_data[:foo_0])) + .and_call_original + expect(foo_feature_factories[:foo_1]) + .to receive(:create) + .with(equal(component), equal(other_input_data), equal(input_data[:foo_1])) + .and_call_original foo_factory.create(parent, other_input_data, input_data) end end describe '受動フィーチャーの生成' do - it '生成したコンポーネントを引数として、受動フィーチャーを生成する' do - expect(foo_feature_factories[:foo_2]).to receive(:create).with(equal(component)).and_call_original + it '生成したコンポーネントと与えられた引数の末尾以外を引数として、受動フィーチャーを生成する' do + expect(foo_feature_factories[:foo_2]) + .to receive(:create) + .with(equal(component)) + .and_call_original + foo_factory.create(parent, input_data) + + expect(foo_feature_factories[:foo_2]) + .to receive(:create) + .with(equal(component), equal(other_input_data)) + .and_call_original foo_factory.create(parent, other_input_data, input_data) end end @@ -199,8 +224,12 @@ def read_file(file) foo_factory.create(other_input_data, input_files) - expect(foo_feature_factories[:foo_0]).to have_received(:create).with(anything, equal(input_datas[1][:foo_0])) - expect(bar_factory).to have_received(:create).with(anything, anything, equal(input_datas[0])) + expect(foo_feature_factories[:foo_0]) + .to have_received(:create) + .with(anything, anything, equal(input_datas[1][:foo_0])) + expect(bar_factory) + .to have_received(:create) + .with(anything, anything, equal(input_datas[0])) end end @@ -215,9 +244,11 @@ def read_file(file) context '空のファイルリストを与えた場合' do it '欠損値使って、自身の組み立てを行う' do expect(foo_feature_factories[:foo_0]) - .to receive(:create).with(anything, equal(RgGen::Core::InputBase::NAValue)) + .to receive(:create) + .with(anything, anything, equal(RgGen::Core::InputBase::NAValue)) expect(foo_feature_factories[:foo_1]) - .to receive(:create).with(anything, equal(RgGen::Core::InputBase::NAValue)) + .to receive(:create) + .with(anything, anything, equal(RgGen::Core::InputBase::NAValue)) expect(bar_factory) .not_to receive(:create) foo_factory.create(other_input_data, [])