Geminstaller C0 Coverage Information - RCov

/Users/woolley/.rvm/gems/ruby-1.8.7-p174@geminstaller/gems/rspec-1.3.0/lib/spec/matchers/wrap_expectation.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/wrap_expectation.rb 55 13
81.82%
23.08%

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     # wraps an expectation in a block that will return true if the
4     # expectation passes and false if it fails (without bubbling up
5     # the failure).
6     #     
7     # This is intended to be used in the context of a simple matcher,
8     # and is especially useful for wrapping multiple expectations or
9     # one or more assertions from test/unit extensions when running
10     # with test/unit.
11     #
12     # == Examples
13     #
14     #   def eat_cheese(cheese)
15     #     simple_matcher do |mouse, matcher|
16     #       matcher.failure_message = "expected #{mouse} to eat cheese"
17     #       wrap_expectation do |matcher|
18     #         assert_eats_cheese(mouse)
19     #       end
20     #     end
21     #   end
22     #
23     #   describe Mouse do
24     #     it "eats cheese" do
25     #       Mouse.new.should eat_cheese
26     #     end
27     #   end
28     #
29     # You might be wondering "why would I do this if I could just say"
30     # assert_eats_cheese?", a fair question, indeed. You might prefer
31     # to replace the word assert with something more aligned with the
32     # rest of your code examples. You are using rspec, after all.
33     #
34     # The other benefit you get is that you can use the negative version
35     # of the matcher:
36     #
37     #   describe Cat do
38     #     it "does not eat cheese" do
39     #       Cat.new.should_not eat_cheese
40     #     end
41     #   end
42     #
43     # So in the event there is no assert_does_not_eat_cheese available,
44     # you're all set!
45     def wrap_expectation(matcher, &block)
46       begin
47         block.call(matcher)
48         return true
49       rescue Exception => e
50         matcher.failure_message = e.message
51         return false
52       end
53     end
54   end
55 end

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