Rspec Steps C0 Coverage Information - RCov

rcov/ruby/1.8/gems/rspec-mocks-2.5.0/lib/rspec/mocks/mock.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
rcov/ruby/1.8/gems/rspec-mocks-2.5.0/lib/rspec/mocks/mock.rb 79 61
41.77%
24.59%

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

Generated on Fri Apr 22 17:22:41 -0700 2011 with rcov 0.9.8