Class: MarkdownExec::TestHashDelegatorWaitForUserSelectedBlock

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

Instance Method Summary collapse

Instance Method Details

#setupObject



3130
3131
3132
3133
# File 'lib/hash_delegator.rb', line 3130

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

#test_wait_for_user_selected_block_with_back_stateObject



3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
# File 'lib/hash_delegator.rb', line 3135

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



3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
# File 'lib/hash_delegator.rb', line 3149

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