Class: SibaTest::KernelMock

Inherits:
Object
  • Object
show all
Defined in:
lib/siba/helpers/test/kernel_mock.rb

Overview

mocks all Siba::SibaKernel methods

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/siba/helpers/test/kernel_mock.rb', line 7

def method_missing(meth, *args, &block)
  if KernelMock.method_defined? meth
    # do nothing
  else
    super
  end
end

Class Attribute Details

.gets_return_valueObject

the valud ‘siba_kernel.gets’ method will return



26
27
28
# File 'lib/siba/helpers/test/kernel_mock.rb', line 26

def gets_return_value
  @gets_return_value
end

Class Method Details

.mock_all_methodsObject



28
29
30
31
# File 'lib/siba/helpers/test/kernel_mock.rb', line 28

def mock_all_methods
  Siba::KernelPlug.siba_kernel = SibaTest::KernelMock.new
  SibaTest::KernelMock.gets_return_value = nil
end

Instance Method Details

#gets(*args) ⇒ Object



34
35
36
# File 'lib/siba/helpers/test/kernel_mock.rb', line 34

def gets(*args)
  SibaTest::KernelMock.gets_return_value
end

#respond_to?(meth) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/siba/helpers/test/kernel_mock.rb', line 15

def respond_to?(meth)
  if KernelMock.method_defined? meth
    true
  else
    super
  end
end