Geminstaller C0 Coverage Information - RCov

/Users/woolley/.rvm/gems/ruby-1.8.7-p174@geminstaller/gems/rspec-1.3.0/lib/spec/matchers/respond_to.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/respond_to.rb 71 49
52.11%
32.65%

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 RespondTo #:nodoc:
5       def initialize(*names)
6         @names = names
7         @expected_arity = nil
8         @names_not_responded_to = []
9       end
10       
11       def matches?(actual)
12         @actual = actual
13         @names.each do |name|
14           @names_not_responded_to << name unless actual.respond_to?(name) && matches_arity?(actual, name)
15         end
16         return @names_not_responded_to.empty?
17       end
18       
19       def failure_message_for_should
20         "expected #{@actual.inspect} to respond to #{@names_not_responded_to.collect {|name| name.inspect }.join(', ')}#{with_arity}"
21       end
22       
23       def failure_message_for_should_not
24         "expected #{@actual.inspect} not to respond to #{@names.collect {|name| name.inspect }.join(', ')}"
25       end
26       
27       def description
28         "respond to #{pp_names}#{with_arity}"
29       end
30       
31       def with(n)
32         @expected_arity = n
33         self
34       end
35       
36       def argument
37         self
38       end
39       alias :arguments :argument
40       
41     private
42       
43       def matches_arity?(actual, name)
44         @expected_arity.nil?? true : @expected_arity == actual.method(name).arity 
45       end
46       
47       def with_arity
48         @expected_arity.nil?? "" :
49           " with #{@expected_arity} argument#{@expected_arity == 1 ? '' : 's'}"
50       end
51       
52       def pp_names
53         # Ruby 1.9 returns the same thing for array.to_s as array.inspect, so just use array.inspect here
54         @names.length == 1 ? "##{@names.first}" : @names.inspect
55       end
56     end
57     
58     # :call-seq:
59     #   should respond_to(*names)
60     #   should_not respond_to(*names)
61     #
62     # Matches if the target object responds to all of the names
63     # provided. Names can be Strings or Symbols.
64     #
65     # == Examples
66     # 
67     def respond_to(*names)
68       Matchers::RespondTo.new(*names)
69     end
70   end
71 end

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