Class: MarkdownExec::TestHashDelegatorWaitForUserSelectedBlock

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

Instance Method Summary collapse

Instance Method Details

#setupObject



3228
3229
3230
3231
# File 'lib/hash_delegator.rb', line 3228

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

#test_wait_for_user_selected_block_with_back_stateObject



3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
# File 'lib/hash_delegator.rb', line 3233

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



3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
# File 'lib/hash_delegator.rb', line 3247

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