Geminstaller C0 Coverage Information - RCov

/Users/woolley/.rvm/gems/ruby-1.8.7-p174@geminstaller/gems/rspec-1.3.0/lib/spec/mocks/methods.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/methods.rb 94 61
69.15%
52.46%

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     module Methods
4       def should_receive(sym, opts={}, &block)
5         __mock_proxy.add_message_expectation(opts[:expected_from] || caller(1)[0], sym.to_sym, opts, &block)
6       end
7 
8       def should_not_receive(sym, &block)
9         __mock_proxy.add_negative_message_expectation(caller(1)[0], sym.to_sym, &block)
10       end
11       
12       def stub!(sym_or_hash, opts={}, &block)
13         if Hash === sym_or_hash
14           sym_or_hash.each {|method, value| stub!(method).and_return value }
15         else
16           __mock_proxy.add_stub(caller(1)[0], sym_or_hash.to_sym, opts, &block)
17         end
18       end
19       
20       alias_method :stub, :stub!
21 
22       def unstub!(message)
23         __mock_proxy.remove_stub(message)
24       end
25 
26       alias_method :unstub, :unstub!
27 
28       # :call-seq:
29       #   object.stub_chain(:first, :second, :third).and_return(:this)
30       #
31       # Supports stubbing a chain of methods. Each argument represents
32       # a method name to stub, and each one returns a proxy object that
33       # can accept more stubs, until the last, which returns whatever
34       # is passed to +and_return_.
35       #
36       # == Examples
37       #   
38       #   # with this in an example ...
39       #   article = double('article')
40       #   Article.stub_chain(:authored_by, :published, :recent).and_return([article])
41       #   # then this will return an Array with the article double in it:
42       #   Article.authored_by(params[:author_id]).published.recent
43       def stub_chain(*methods)
44         if methods.length > 1
45           if matching_stub = __mock_proxy.find_matching_method_stub(methods[0])
46             methods.shift
47             matching_stub.invoke_return_block.stub_chain(*methods)
48           else
49             next_in_chain = Object.new
50             stub!(methods.shift) {next_in_chain}
51             next_in_chain.stub_chain(*methods)
52           end
53         else
54           stub!(methods.shift)
55         end
56       end
57       
58       # Record and otherwise ignore all messages that aren't specified,
59       # with +stub+, +stub!+, or +should_receive+.
60       # 
61       # == Returns
62       #   self
63       def as_null_object
64         __mock_proxy.as_null_object
65       end
66       
67       def null_object?
68         __mock_proxy.null_object?
69       end
70       
71       def received_message?(sym, *args, &block) #:nodoc:
72         __mock_proxy.received_message?(sym.to_sym, *args, &block)
73       end
74       
75       def rspec_verify #:nodoc:
76         __mock_proxy.verify
77       end
78 
79       def rspec_reset #:nodoc:
80         __mock_proxy.reset
81       end
82 
83     private
84 
85       def __mock_proxy
86         if Mock === self
87           @mock_proxy ||= Proxy.new(self, @name, @options)
88         else
89           @mock_proxy ||= Proxy.new(self)
90         end
91       end
92     end
93   end
94 end

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