Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
---|---|---|---|---|
rcov/ruby/1.8/gems/rspec-expectations-2.5.0/lib/rspec/matchers/satisfy.rb | 51 | 26 | 66.67%
|
34.62%
|
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 Matchers |
3 |
4 class Satisfy #:nodoc: |
5 def initialize(&block) |
6 @block = block |
7 end |
8 |
9 def matches?(actual, &block) |
10 @block = block if block |
11 @actual = actual |
12 @block.call(actual) |
13 end |
14 |
15 def failure_message_for_should |
16 "expected #{@actual} to satisfy block" |
17 end |
18 |
19 def failure_message_for_should_not |
20 "expected #{@actual} not to satisfy block" |
21 end |
22 |
23 def description |
24 "satisfy block" |
25 end |
26 end |
27 |
28 # :call-seq: |
29 # should satisfy {} |
30 # should_not satisfy {} |
31 # |
32 # Passes if the submitted block returns true. Yields target to the |
33 # block. |
34 # |
35 # Generally speaking, this should be thought of as a last resort when |
36 # you can't find any other way to specify the behaviour you wish to |
37 # specify. |
38 # |
39 # If you do find yourself in such a situation, you could always write |
40 # a custom matcher, which would likely make your specs more expressive. |
41 # |
42 # == Examples |
43 # |
44 # 5.should satisfy { |n| |
45 # n > 3 |
46 # } |
47 def satisfy(&block) |
48 Matchers::Satisfy.new(&block) |
49 end |
50 end |
51 end |
Generated on Fri Apr 22 17:22:41 -0700 2011 with rcov 0.9.8