Rspec Steps C0 Coverage Information - RCov

rcov/ruby/1.8/gems/rspec-expectations-2.5.0/lib/rspec/expectations/fail_with.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
rcov/ruby/1.8/gems/rspec-expectations-2.5.0/lib/rspec/expectations/fail_with.rb 51 38
41.18%
26.32%

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 Expectations
3     class << self
4       def differ
5         @differ ||= Differ.new
6       end
7       
8       # raises a RSpec::Expectations::ExpectationNotMetError with message
9       #
10       # When a differ has been assigned and fail_with is passed
11       # <code>expected</code> and <code>actual</code>, passes them
12       # to the differ to append a diff message to the failure message.
13       def fail_with(message, expected=nil, actual=nil) # :nodoc:
14         if !message
15           raise ArgumentError, "Failure message is nil. Does your matcher define the " +
16                                "appropriate failure_message_for_* method to return a string?"
17         end
18 
19         if actual && expected
20           if all_strings?(actual, expected)
21             if any_multiline_strings?(actual, expected)
22               message << "\nDiff:" << self.differ.diff_as_string(actual, expected)
23             end
24           elsif no_procs?(actual, expected) && no_numbers?(actual, expected)
25             message << "\nDiff:" << self.differ.diff_as_object(actual, expected)
26           end
27         end
28 
29         raise(RSpec::Expectations::ExpectationNotMetError.new(message))
30       end
31 
32     private
33 
34       def no_procs?(*args)
35         args.none? {|a| Proc === a}
36       end
37 
38       def all_strings?(*args)
39         args.all? {|a| String === a}
40       end
41 
42       def any_multiline_strings?(*args)
43         all_strings?(*args) && args.any? {|a| a =~ /\n/}
44       end
45 
46       def no_numbers?(*args)
47         args.none? {|a| Numeric === a}
48       end
49     end
50   end
51 end

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