Class: MarkdownExec::TestHashDelegator::TestHashDelegatorCommandOrUserSelectedBlock

Inherits:
Minitest::Test
  • Object
show all
Defined in:
lib/hash_delegator.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



2680
2681
2682
2683
2684
2685
# File 'lib/hash_delegator.rb', line 2680

def setup
  @hd = HashDelegator.new
  @hd.instance_variable_set(:@delegate_object, {})
  HashDelegator.stubs(:error_handler)
  @hd.stubs(:wait_for_user_selected_block)
end

#test_command_selected_blockObject



2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
# File 'lib/hash_delegator.rb', line 2687

def test_command_selected_block
  all_blocks = [{ oname: 'block1' }, { oname: 'block2' }]
  @hd.instance_variable_set(:@delegate_object,
                            { block_name: 'block1' })

  result = @hd.load_cli_or_user_selected_block(all_blocks: all_blocks)

  assert_equal all_blocks.first.merge(block_name_from_ui: false), result.block
  assert_nil result.state
end

#test_user_selected_blockObject



2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
# File 'lib/hash_delegator.rb', line 2698

def test_user_selected_block
  block_state = SelectedBlockMenuState.new({ oname: 'block2' },
                                           :some_state)
  @hd.stubs(:wait_for_user_selected_block).returns(block_state)

  result = @hd.load_cli_or_user_selected_block

  assert_equal block_state.block.merge(block_name_from_ui: true), result.block
  assert_equal :some_state, result.state
end