Module: RR

Extended by:
DSL
Defined in:
lib/rr/dsl.rb,
lib/rr/space.rb,
lib/rr/double.rb,
lib/rr/errors.rb,
lib/rr/version.rb,
lib/rr/autohook.rb,
lib/rr/blank_slate.rb,
lib/rr/deprecations.rb,
lib/rr/integrations.rb,
lib/rr/recorded_call.rb,
lib/rr/double_matches.rb,
lib/rr/recorded_calls.rb,
lib/rr/errors/rr_error.rb,
lib/rr/spy_verification.rb,
lib/rr/without_autohook.rb,
lib/rr/keyword_arguments.rb,
lib/rr/injections/injection.rb,
lib/rr/integrations/rspec_2.rb,
lib/rr/integrations/minitest.rb,
lib/rr/integrations/decorator.rb,
lib/rr/spy_verification_proxy.rb,
lib/rr/wildcard_matchers/is_a.rb,
lib/rr/hash_with_object_id_key.rb,
lib/rr/integrations/minitest_4.rb,
lib/rr/errors/double_order_error.rb,
lib/rr/errors/times_called_error.rb,
lib/rr/wildcard_matchers/boolean.rb,
lib/rr/wildcard_matchers/numeric.rb,
lib/rr/wildcard_matchers/satisfy.rb,
lib/rr/wildcard_matchers/anything.rb,
lib/rr/injections/double_injection.rb,
lib/rr/wildcard_matchers/duck_type.rb,
lib/rr/class_instance_method_defined.rb,
lib/rr/errors/double_not_found_error.rb,
lib/rr/errors/double_definition_error.rb,
lib/rr/times_called_matchers/terminal.rb,
lib/rr/wildcard_matchers/hash_including.rb,
lib/rr/method_dispatches/method_dispatch.rb,
lib/rr/times_called_matchers/non_terminal.rb,
lib/rr/times_called_matchers/proc_matcher.rb,
lib/rr/injections/method_missing_injection.rb,
lib/rr/times_called_matchers/never_matcher.rb,
lib/rr/times_called_matchers/range_matcher.rb,
lib/rr/double_definitions/double_definition.rb,
lib/rr/integrations/minitest_active_support.rb,
lib/rr/expectations/any_argument_expectation.rb,
lib/rr/expectations/times_called_expectation.rb,
lib/rr/integrations/rspec/invocation_matcher.rb,
lib/rr/times_called_matchers/at_most_matcher.rb,
lib/rr/times_called_matchers/integer_matcher.rb,
lib/rr/double_definitions/strategies/strategy.rb,
lib/rr/integrations/minitest_4_active_support.rb,
lib/rr/method_dispatches/base_method_dispatch.rb,
lib/rr/times_called_matchers/at_least_matcher.rb,
lib/rr/times_called_matchers/any_times_matcher.rb,
lib/rr/errors/subject_has_different_arity_error.rb,
lib/rr/method_dispatches/method_missing_dispatch.rb,
lib/rr/expectations/argument_equality_expectation.rb,
lib/rr/times_called_matchers/times_called_matcher.rb,
lib/rr/double_definitions/double_definition_create.rb,
lib/rr/injections/singleton_method_added_injection.rb,
lib/rr/double_definitions/double_injections/instance.rb,
lib/rr/double_definitions/strategies/strategy_methods.rb,
lib/rr/errors/subject_does_not_implement_method_error.rb,
lib/rr/double_definitions/strategies/verification/mock.rb,
lib/rr/double_definitions/strategies/verification/stub.rb,
lib/rr/double_definitions/child_double_definition_create.rb,
lib/rr/double_definitions/strategies/implementation/proxy.rb,
lib/rr/double_definitions/double_injections/any_instance_of.rb,
lib/rr/double_definitions/strategies/verification/dont_allow.rb,
lib/rr/errors/spy_verification_errors/invocation_count_error.rb,
lib/rr/errors/spy_verification_errors/spy_verification_error.rb,
lib/rr/double_definitions/double_definition_create_blank_slate.rb,
lib/rr/double_definitions/strategies/double_injection/instance.rb,
lib/rr/double_definitions/strategies/implementation/reimplementation.rb,
lib/rr/double_definitions/strategies/double_injection/any_instance_of.rb,
lib/rr/errors/spy_verification_errors/double_injection_not_found_error.rb,
lib/rr/double_definitions/strategies/verification/verification_strategy.rb,
lib/rr/double_definitions/strategies/implementation/implementation_strategy.rb,
lib/rr/double_definitions/strategies/double_injection/double_injection_strategy.rb,
lib/rr/double_definitions/strategies/implementation/strongly_typed_reimplementation.rb

Defined Under Namespace

Modules: Adapters, BlankSlate, ClassInstanceMethodDefined, DSL, Deprecations, DoubleDefinitions, Errors, Expectations, Extensions, Injections, Integrations, KeywordArguments, MethodDispatches, TimesCalledMatchers, WildcardMatchers Classes: Double, DoubleMatches, HashWithObjectIdKey, RecordedCall, RecordedCalls, Space, SpyVerification, SpyVerificationProxy

Constant Summary collapse

VERSION =
'3.0.4'.freeze

Constants included from DSL

DSL::METHODS_TO_EXCLUDE_FROM_SPYING

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from DSL

any_instance_of, any_times, anything, boolean, dont_allow, duck_type, hash_including, instance_of, is_a, mock, numeric, proxy, received, reset, satisfy, spy, strong, stub, verify

Methods included from DoubleDefinitions::Strategies::StrategyMethods

#any_instance_of!, #dont_allow!, #instance_of!, #mock!, #proxy!, #strong!, #stub!

Class Attribute Details

.debugObject Also known as: debug?

Returns the value of attribute debug.



115
116
117
# File 'lib/rr/without_autohook.rb', line 115

def debug
  @debug
end

.overridden_error_classObject

Returns the value of attribute overridden_error_class.



3
4
5
# File 'lib/rr/errors.rb', line 3

def overridden_error_class
  @overridden_error_class
end

Class Method Details

.adaptersObject



15
16
17
# File 'lib/rr/integrations.rb', line 15

def self.adapters
  @adapters ||= []
end

.adapters_by_nameObject



19
20
21
# File 'lib/rr/integrations.rb', line 19

def self.adapters_by_name
  @adapters_by_name ||= {}
end

.applicable_adaptersObject



29
30
31
# File 'lib/rr/integrations.rb', line 29

def self.applicable_adapters
  adapters.select { |adapter| adapter.applies? }
end

.autohookObject



3
4
5
6
7
8
# File 'lib/rr/autohook.rb', line 3

def autohook
  applicable_adapters.each { |adapter| adapter.load }
  if applicable_adapters.empty?
    puts "No adapters matched!" if RR.debug?
  end
end

.find_applicable_adapter(name) ⇒ Object



33
34
35
36
37
# File 'lib/rr/integrations.rb', line 33

def self.find_applicable_adapter(name)
  adapters.
    select { |adapter| name === adapter.name.to_s }.
    find   { |adapter| adapter.applies? }
end

.loaded_adapter_namesObject



23
24
25
26
27
# File 'lib/rr/integrations.rb', line 23

def self.loaded_adapter_names
  adapters.
    select { |adapter| adapter.loaded? }.
    map { |adapter| adapter.name }
end

.module_shim_for_adapter(adapter) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rr/integrations.rb', line 39

def self.module_shim_for_adapter(adapter)
  mod = Module.new
  (class << mod; self; end).class_eval do
    define_method(:included) do |base|
      # Note: This assumes that the thing that is including this module
      # is the same that the adapter detected and will hook into.
      adapter.load
    end
  end
  mod
end

.register_adapter(klass) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/rr/integrations.rb', line 7

def self.register_adapter(klass)
  adapter = Integrations::Decorator.new(klass.new)
  unless adapters_by_name.key?(adapter.name)
    adapters << adapter
    adapters_by_name[adapter.name] = adapter
  end
end

.versionObject



3
# File 'lib/rr/version.rb', line 3

def self.version; VERSION; end