Geminstaller C0 Coverage Information - RCov

/Users/woolley/.rvm/gems/ruby-1.8.7-p174@geminstaller/gems/rspec-1.3.0/lib/spec/matchers/operator_matcher.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/matchers/operator_matcher.rb 78 62
74.36%
72.58%

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 Matchers
3 
4     class OperatorMatcher
5       class << self
6         def registry
7           @registry ||= {}
8         end
9 
10         def register(klass, operator, matcher)
11           registry[klass] ||= {}
12           registry[klass][operator] = matcher
13         end
14 
15         def get(klass, operator)
16           registry[klass] && registry[klass][operator]
17         end
18       end
19 
20       def initialize(actual)
21         @actual = actual
22       end
23 
24       def self.use_custom_matcher_or_delegate(operator)
25         define_method(operator) do |expected|
26           if matcher = OperatorMatcher.get(@actual.class, operator)
27             @actual.send(::Spec::Matchers.last_should, matcher.new(expected))
28           else
29             eval_match(@actual, operator, expected)
30           end
31         end
32       end
33 
34       ['==', '===', '=~', '>', '>=', '<', '<='].each do |operator|
35         use_custom_matcher_or_delegate operator
36       end
37 
38       def fail_with_message(message)
39         Spec::Expectations.fail_with(message, @expected, @actual)
40       end
41 
42       def description
43         "#{@operator} #{@expected.inspect}"
44       end
45       
46     private
47       
48       def eval_match(actual, operator, expected)
49         ::Spec::Matchers.last_matcher = self
50         @operator, @expected = operator, expected
51         __delegate_operator(actual, operator, expected)
52       end
53 
54     end
55 
56     class PositiveOperatorMatcher < OperatorMatcher #:nodoc:
57       def __delegate_operator(actual, operator, expected)
58         if actual.__send__(operator, expected)
59           true
60         elsif ['==','===', '=~'].include?(operator)
61           fail_with_message("expected: #{expected.inspect},\n     got: #{actual.inspect} (using #{operator})") 
62         else
63           fail_with_message("expected: #{operator} #{expected.inspect},\n     got: #{operator.gsub(/./, ' ')} #{actual.inspect}")
64         end
65       end
66 
67     end
68 
69     class NegativeOperatorMatcher < OperatorMatcher #:nodoc:
70       def __delegate_operator(actual, operator, expected)
71         return false unless actual.__send__(operator, expected)
72         return fail_with_message("expected not: #{operator} #{expected.inspect},\n         got: #{operator.gsub(/./, ' ')} #{actual.inspect}")
73       end
74 
75     end
76 
77   end
78 end

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