Class: MarkdownExec::TestHashDelegator::TestHashDelegatorHandleBlockState

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

Instance Method Summary collapse

Instance Method Details

#setupObject



2851
2852
2853
2854
# File 'lib/hash_delegator.rb', line 2851

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

#test_handle_back_or_continue_with_backObject



2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
# File 'lib/hash_delegator.rb', line 2856

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



2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
# File 'lib/hash_delegator.rb', line 2867

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



2878
2879
2880
2881
2882
2883
2884
2885
2886
# File 'lib/hash_delegator.rb', line 2878

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