Class | RR::Space |
In: |
lib/rr/space.rb
|
Parent: | Object |
RR::Space.instance is the global state subject for the RR framework.
instance | [W] | |
ordered_doubles | [R] | |
recorded_calls | [R] | |
trim_backtrace | [RW] |
# File lib/rr/space.rb, line 24 24: def initialize 25: @ordered_doubles = [] 26: @trim_backtrace = false 27: @recorded_calls = RR::RecordedCalls.new 28: end
# File lib/rr/space.rb, line 17 17: def method_missing(method_name, *args, &block) 18: instance.__send__(method_name, *args, &block) 19: end
# File lib/rr/space.rb, line 82 82: def blank_slate_whitelist 83: @blank_slate_whitelist ||= [ 84: "object_id", "respond_to?", "respond_to_missing?", "method_missing", "instance_eval", "instance_exec", "class_eval" 85: ] 86: end
# File lib/rr/space.rb, line 78 78: def record_call(subject, method_name, arguments, block) 79: @recorded_calls << [subject, method_name, arguments, block] 80: end
Resets the registered Doubles and ordered Doubles
# File lib/rr/space.rb, line 60 60: def reset 61: reset_ordered_doubles 62: Injections::DoubleInjection.reset 63: reset_method_missing_injections 64: reset_singleton_method_added_injections 65: reset_recorded_calls 66: end
Resets the DoubleInjection for the passed in subject and method_name.
# File lib/rr/space.rb, line 74 74: def reset_double(subject, method_name) 75: Injections::DoubleInjection.reset_double(class << subject; self; end, method_name) 76: end
Verifies the DoubleInjection for the passed in subject and method_name.
# File lib/rr/space.rb, line 69 69: def verify_double(subject, method_name) 70: Injections::DoubleInjection.verify_double(class << subject; self; end, method_name) 71: end
Verifies all the DoubleInjection objects have met their TimesCalledExpectations.
# File lib/rr/space.rb, line 54 54: def verify_doubles(*subjects) 55: Injections::DoubleInjection.verify(*subjects) 56: end
Verifies that the passed in ordered Double is being called in the correct position.
# File lib/rr/space.rb, line 37 37: def verify_ordered_double(double) 38: unless double.terminal? 39: raise Errors::DoubleOrderError, 40: "Ordered Doubles cannot have a NonTerminal TimesCalledExpectation" 41: end 42: unless @ordered_doubles.first == double 43: message = Double.formatted_name(double.method_name, double.expected_arguments) 44: message << " called out of order in list\n" 45: message << Double.list_message_part(@ordered_doubles) 46: raise Errors::DoubleOrderError, message 47: end 48: @ordered_doubles.shift unless double.attempt? 49: double 50: end
# File lib/rr/space.rb, line 94 94: def reset_method_missing_injections 95: Injections::MethodMissingInjection.instances.each do |subject_class, injection| 96: injection.reset 97: end 98: Injections::MethodMissingInjection.instances.clear 99: end
Removes the ordered Doubles from the list
# File lib/rr/space.rb, line 90 90: def reset_ordered_doubles 91: @ordered_doubles.clear 92: end