Class: MarkdownExec::TestHashDelegatorWaitForUserSelectedBlock

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

Instance Method Summary collapse

Instance Method Details

#setupObject



3342
3343
3344
3345
# File 'lib/hash_delegator.rb', line 3342

def setup
  @hd = HashDelegator.new
  HashDelegator.stubs(:error_handler)
end

#test_wait_for_user_selected_block_with_back_stateObject



3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
# File 'lib/hash_delegator.rb', line 3347

def test_wait_for_user_selected_block_with_back_state
  mock_block_state = Struct.new(:state, :block).new(MenuState::BACK,
                                                    { oname: 'back_block' })
  @hd.stubs(:wait_for_user_selection).returns(mock_block_state)

  result = @hd.wait_for_user_selected_block([], ['Block 1', 'Block 2'],
                                            nil)

  assert_equal 'back_block',
               @hd.instance_variable_get(:@delegate_object)[:block_name]
  assert @hd.instance_variable_get(:@menu_user_clicked_back_link)
  assert_equal mock_block_state, result
end

#test_wait_for_user_selected_block_with_continue_stateObject



3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
# File 'lib/hash_delegator.rb', line 3361

def test_wait_for_user_selected_block_with_continue_state
  mock_block_state = Struct.new(:state, :block).new(
    MenuState::CONTINUE, { oname: 'continue_block' }
  )
  @hd.stubs(:wait_for_user_selection).returns(mock_block_state)

  result = @hd.wait_for_user_selected_block([], ['Block 1', 'Block 2'],
                                            nil)

  assert_equal 'continue_block',
               @hd.instance_variable_get(:@delegate_object)[:block_name]
  refute @hd.instance_variable_get(:@menu_user_clicked_back_link)
  assert_equal mock_block_state, result
end