Class: MarkdownExec::TestHashDelegatorWaitForUserSelectedBlock

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

Instance Method Summary collapse

Instance Method Details

#setupObject



3284
3285
3286
3287
# File 'lib/hash_delegator.rb', line 3284

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

#test_wait_for_user_selected_block_with_back_stateObject



3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
# File 'lib/hash_delegator.rb', line 3289

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



3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
# File 'lib/hash_delegator.rb', line 3303

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