Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
---|---|---|---|---|
rcov/ruby/1.8/gems/rspec-mocks-2.5.0/lib/rspec/mocks/argument_expectation.rb | 53 | 44 | 37.74%
|
27.27%
|
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.
1 module RSpec |
2 module Mocks |
3 class ArgumentExpectation |
4 attr_reader :args |
5 |
6 def initialize(*args, &block) |
7 @args = args |
8 @matchers_block = args.empty? ? block : nil |
9 @match_any_args = false |
10 @matchers = nil |
11 |
12 case args.first |
13 when ArgumentMatchers::AnyArgsMatcher |
14 @match_any_args = true |
15 when ArgumentMatchers::NoArgsMatcher |
16 @matchers = [] |
17 else |
18 @matchers = args.collect {|arg| matcher_for(arg)} |
19 end |
20 end |
21 |
22 def matcher_for(arg) |
23 return ArgumentMatchers::MatcherMatcher.new(arg) if is_matcher?(arg) |
24 return ArgumentMatchers::RegexpMatcher.new(arg) if arg.is_a?(Regexp) |
25 return ArgumentMatchers::EqualityProxy.new(arg) |
26 end |
27 |
28 def is_matcher?(obj) |
29 !is_stub_as_null_object?(obj) & obj.respond_to?(:matches?) & obj.respond_to?(:description) |
30 end |
31 |
32 def is_stub_as_null_object?(obj) |
33 obj.respond_to?(:__rspec_double_acting_as_null_object?) && obj.__rspec_double_acting_as_null_object? |
34 end |
35 |
36 def args_match?(*args) |
37 match_any_args? || matchers_block_matches?(*args) || matchers_match?(*args) |
38 end |
39 |
40 def matchers_block_matches?(*args) |
41 @matchers_block ? @matchers_block.call(*args) : nil |
42 end |
43 |
44 def matchers_match?(*args) |
45 @matchers == args |
46 end |
47 |
48 def match_any_args? |
49 @match_any_args |
50 end |
51 end |
52 end |
53 end |
Generated on Fri Apr 22 17:22:41 -0700 2011 with rcov 0.9.8