Module: Ribbon::Intercom::Utils::Mixins::MockSafe

Included in:
Client::SDK, Package
Defined in:
lib/ribbon/intercom/utils/mixins/mock_safe.rb

Instance Method Summary collapse

Instance Method Details

#mock_safeObject

Return a mock safe version of this package.



6
7
8
# File 'lib/ribbon/intercom/utils/mixins/mock_safe.rb', line 6

def mock_safe
  dup.tap { |obj| obj.mock_safe! }
end

#mock_safe!Object

Make this package mock safe.



12
13
14
15
16
17
18
19
# File 'lib/ribbon/intercom/utils/mixins/mock_safe.rb', line 12

def mock_safe!
  unless mock_safe?
    @_mock_safe = true

    # For RSpec: Allow any method to be mocked on this instance.
    define_singleton_method(:respond_to?) { |*args| true }
  end
end

#mock_safe?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/ribbon/intercom/utils/mixins/mock_safe.rb', line 21

def mock_safe?
  !!@_mock_safe
end