Methods

Class Index [+]

Quicksearch

RR::DoubleDefinitions::Strategies::Scope::InstanceOfClass

Calling instance_of will cause all instances of the passed in Class to have the Double defined.

The following example mocks all User’s valid? method and return false.

  mock.instance_of(User).valid? {false}

The following example mocks and proxies User#projects and returns the first 3 projects.

  mock.instance_of(User).projects do |projects|
    projects[0..2]
  end        

Public Class Methods

new(*args) click to toggle source
    # File lib/rr/double_definitions/strategies/scope/instance_of_class.rb, line 19
19:           def initialize(*args)
20:             super
21: 
22:             if !double_definition_create.no_subject? && !double_definition_create.subject.is_a?(Class)
23:               raise ArgumentError, "instance_of only accepts class objects"
24:             end
25:           end

Protected Instance Methods

do_call() click to toggle source
    # File lib/rr/double_definitions/strategies/scope/instance_of_class.rb, line 28
28:           def do_call
29:             instance_of_subject_double_definition_create = DoubleDefinitionCreate.new
30:             instance_of_subject_double_definition_create.strong if definition.verify_method_signature?
31:             instance_of_subject_double_definition_create.stub(subject)
32:             instance_of_subject_double_definition_create.call(:new) do |*args|
33:               #####
34:               instance = subject.allocate
35:               double_injection = Injections::DoubleInjection.create(instance, method_name)
36:               Double.new(double_injection, definition)
37:               #####
38:               if args.last.is_a?(ProcFromBlock)
39:                 instance.__send__(:initialize, *args[0..(args.length-2)], &args.last)
40:               else
41:                 instance.__send__(:initialize, *args)
42:               end
43:               instance
44:             end
45:           end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.