Class: MarkdownExec::TestHashDelegator::TestHashDelegatorHandleBlockState

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

Instance Method Summary collapse

Instance Method Details

#setupObject



2949
2950
2951
2952
# File 'lib/hash_delegator.rb', line 2949

def setup
  @hd = HashDelegator.new
  @mock_block_state = mock('block_state')
end

#test_handle_back_or_continue_with_backObject



2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
# File 'lib/hash_delegator.rb', line 2954

def test_handle_back_or_continue_with_back
  @mock_block_state.stubs(:state).returns(MenuState::BACK)
  @mock_block_state.stubs(:block).returns({ oname: 'sample_block' })

  @hd.handle_back_or_continue(@mock_block_state)

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

#test_handle_back_or_continue_with_continueObject



2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
# File 'lib/hash_delegator.rb', line 2965

def test_handle_back_or_continue_with_continue
  @mock_block_state.stubs(:state).returns(MenuState::CONTINUE)
  @mock_block_state.stubs(:block).returns({ oname: 'another_block' })

  @hd.handle_back_or_continue(@mock_block_state)

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

#test_handle_back_or_continue_with_otherObject



2976
2977
2978
2979
2980
2981
2982
2983
2984
# File 'lib/hash_delegator.rb', line 2976

def test_handle_back_or_continue_with_other
  @mock_block_state.stubs(:state).returns(nil) # MenuState::OTHER
  @mock_block_state.stubs(:block).returns({ oname: 'other_block' })

  @hd.handle_back_or_continue(@mock_block_state)

  assert_nil @hd.instance_variable_get(:@delegate_object)[:block_name]
  assert_nil @hd.instance_variable_get(:@menu_user_clicked_back_link)
end