Class: MarkdownExec::TestHashDelegatorHandleBlockState

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

Instance Method Summary collapse

Instance Method Details

#setupObject



4822
4823
4824
4825
# File 'lib/hash_delegator.rb', line 4822

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

#test_handle_back_or_continue_with_backObject



4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
# File 'lib/hash_delegator.rb', line 4827

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



4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
# File 'lib/hash_delegator.rb', line 4838

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



4849
4850
4851
4852
4853
4854
4855
4856
4857
# File 'lib/hash_delegator.rb', line 4849

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