In Files

Parent

Namespace

Class/Module Index [+]

Quicksearch

RR::Space

RR::Space.instance is the global state subject for the RR framework.

Attributes

instance[W]
ordered_doubles[R]
recorded_calls[R]
trim_backtrace[RW]

Public Class Methods

instance() click to toggle source
# File lib/rr/space.rb, line 11
def instance
  @instance ||= new
end
new() click to toggle source
# File lib/rr/space.rb, line 24
def initialize
  @ordered_doubles = []
  @trim_backtrace = false
  @recorded_calls = RR::RecordedCalls.new
end

Protected Class Methods

method_missing(method_name, *args, &block) click to toggle source
# File lib/rr/space.rb, line 17
def method_missing(method_name, *args, &block)
  instance.__send__(method_name, *args, &block)
end

Public Instance Methods

blank_slate_whitelist() click to toggle source
# File lib/rr/space.rb, line 82
def blank_slate_whitelist
  @blank_slate_whitelist ||= [
    "object_id", "respond_to?", "method_missing", "instance_eval", "instance_exec", "class_eval"
  ]
end
record_call(subject, method_name, arguments, block) click to toggle source
# File lib/rr/space.rb, line 78
def record_call(subject, method_name, arguments, block)
  @recorded_calls << [subject, method_name, arguments, block]
end
register_ordered_double(double) click to toggle source

Registers the ordered Double to be verified.

# File lib/rr/space.rb, line 31
def register_ordered_double(double)
  @ordered_doubles << double unless ordered_doubles.include?(double)
end
reset() click to toggle source

Resets the registered Doubles and ordered Doubles

# File lib/rr/space.rb, line 60
def reset
  reset_ordered_doubles
  Injections::DoubleInjection.reset
  reset_method_missing_injections
  reset_singleton_method_added_injections
  reset_recorded_calls
end
reset_double(subject, method_name) click to toggle source

Resets the DoubleInjection for the passed in subject and method_name.

# File lib/rr/space.rb, line 74
def reset_double(subject, method_name)
  Injections::DoubleInjection.reset_double(subject, method_name)
end
verify(*subjects) click to toggle source
Alias for: verify_doubles
verify_double(subject, method_name) click to toggle source

Verifies the DoubleInjection for the passed in subject and method_name.

# File lib/rr/space.rb, line 69
def verify_double(subject, method_name)
  Injections::DoubleInjection.verify_double(subject, method_name)
end
verify_doubles(*subjects) click to toggle source

Verifies all the DoubleInjection objects have met their TimesCalledExpectations.

# File lib/rr/space.rb, line 54
def verify_doubles(*subjects)
  Injections::DoubleInjection.verify(*subjects)
end
Also aliased as: verify
verify_ordered_double(double) click to toggle source

Verifies that the passed in ordered Double is being called in the correct position.

# File lib/rr/space.rb, line 37
def verify_ordered_double(double)
  unless double.terminal?
    raise Errors::DoubleOrderError,
          "Ordered Doubles cannot have a NonTerminal TimesCalledExpectation"
  end
  unless @ordered_doubles.first == double
    message = Double.formatted_name(double.method_name, double.expected_arguments)
    message << " called out of order in list\n"
    message << Double.list_message_part(@ordered_doubles)
    raise Errors::DoubleOrderError, message
  end
  @ordered_doubles.shift unless double.attempt?
  double
end

Protected Instance Methods

reset_method_missing_injections() click to toggle source
# File lib/rr/space.rb, line 94
def reset_method_missing_injections
  Injections::MethodMissingInjection.instances.each do |subject, injection|
    injection.reset
  end
  Injections::MethodMissingInjection.instances.clear
end
reset_ordered_doubles() click to toggle source

Removes the ordered Doubles from the list

# File lib/rr/space.rb, line 90
def reset_ordered_doubles
  @ordered_doubles.clear
end
reset_recorded_calls() click to toggle source
# File lib/rr/space.rb, line 108
def reset_recorded_calls
  @recorded_calls.clear
end
reset_singleton_method_added_injections() click to toggle source
# File lib/rr/space.rb, line 101
def reset_singleton_method_added_injections
  Injections::SingletonMethodAddedInjection.instances.each do |subject, injection|
    injection.reset
  end
  Injections::SingletonMethodAddedInjection.instances.clear
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.