Geminstaller C0 Coverage Information - RCov

/Users/woolley/.rvm/gems/ruby-1.8.7-p174@geminstaller/gems/rspec-1.3.0/lib/spec/mocks/mock.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
/Users/woolley/.rvm/gems/ruby-1.8.7-p174@geminstaller/gems/rspec-1.3.0/lib/spec/mocks/mock.rb 71 54
67.61%
57.41%

Key

Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.

Coverage Details

1 module Spec
2   module Mocks
3     class Mock
4       include Methods
5 
6       # Creates a new mock with a +name+ (that will be used in error messages
7       # only) == Options:
8       # * <tt>:null_object</tt> - if true, the mock object acts as a forgiving
9       #   null object allowing any message to be sent to it.
10       def initialize(name=nil, stubs_and_options={})
11         if name.is_a?(Hash) && stubs_and_options.empty?
12           stubs_and_options = name
13           @name = nil
14         else
15           @name = name
16         end
17         @options = extract_options(stubs_and_options)
18         assign_stubs(stubs_and_options)
19       end
20 
21       # This allows for comparing the mock to other objects that proxy such as
22       # ActiveRecords belongs_to proxy objects. By making the other object run
23       # the comparison, we're sure the call gets delegated to the proxy
24       # target.
25       def ==(other)
26         other == __mock_proxy
27       end
28 
29       def inspect
30         "#<#{self.class}:#{sprintf '0x%x', self.object_id} @name=#{@name.inspect}>"
31       end
32 
33       def to_s
34         inspect.gsub('<','[').gsub('>',']')
35       end
36 
37     private
38 
39       def method_missing(sym, *args, &block)
40         __mock_proxy.record_message_received(sym, args, block)
41         begin
42           return self if __mock_proxy.null_object?
43           super(sym, *args, &block)
44         rescue NameError
45           __mock_proxy.raise_unexpected_message_error sym, *args
46         end
47       end
48 
49       def extract_options(stubs_and_options)
50         options = {}
51         extract_option(stubs_and_options, options, :null_object)
52         extract_option(stubs_and_options, options, :__declared_as, 'Mock')
53         options
54       end
55       
56       def extract_option(source, target, key, default=nil)
57         if source[key]
58           target[key] = source.delete(key)
59         elsif default
60           target[key] = default
61         end
62       end
63 
64       def assign_stubs(stubs)
65         stubs.each_pair do |message, response|
66           stub!(message).and_return(response)
67         end
68       end
69     end
70   end
71 end

Generated on Mon May 10 23:40:27 -0700 2010 with rcov 0.9.8