File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed
Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -59,11 +59,11 @@ def add_simple_option(name)
5959 @default_values_for_options ||= { }
6060 @default_values_for_options [ ivar ] = proc { [ nil , proc { } ] }
6161
62- define_method ( name ) do |options , &block |
62+ define_method ( name ) do |options = nil , &block |
6363 old_options , old_block = instance_variable_get ( ivar )
6464
6565 new_options = options || old_options
66- new_block = TableSync :: Utils . proc_keywords_resolver ( & block ) || old_block
66+ new_block = block || old_block
6767
6868 instance_variable_set ( ivar , [ new_options , new_block ] )
6969 end
Original file line number Diff line number Diff line change 349349 end
350350 end
351351
352+ describe "#conditional_handler" do
353+ it "returns correct default value" do
354+ value , callable = config . option ( :conditional_handler )
355+ expect ( value ) . to be_nil
356+ expect ( callable ) . to be_a ( Proc )
357+ end
358+
359+ it "processes a single value" do
360+ config . conditional_handler :test
361+
362+ value , callable = config . option ( :conditional_handler )
363+ expect ( value ) . to eq ( :test )
364+ expect ( callable ) . to be_a ( Proc )
365+ end
366+
367+ it "processes a single block" do
368+ config . conditional_handler { :test }
369+
370+ value , callable = config . option ( :conditional_handler )
371+ expect ( value ) . to be_nil
372+ expect ( callable . call ) . to eq ( :test )
373+ end
374+
375+ it "processes a value and a block" do
376+ config . conditional_handler ( :spam ) { :test }
377+
378+ value , callable = config . option ( :conditional_handler )
379+ expect ( value ) . to eq ( :spam )
380+ expect ( callable . call ) . to eq ( :test )
381+ end
382+ end
383+
352384 %i[ before_update after_commit_on_update before_destroy after_commit_on_destroy ] . each do |option |
353385 describe "##{ option } " do
354386 it "returns correct default value" do
You can’t perform that action at this time.
0 commit comments