Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
---|---|---|---|---|
rcov/ruby/1.8/gems/rspec-expectations-2.5.0/lib/rspec/matchers/exist.rb | 26 | 20 | 30.77%
|
15.00%
|
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 # :call-seq: |
4 # should exist |
5 # should_not exist |
6 # |
7 # Passes if actual.exist? or actual.exists? |
8 def exist(*args) |
9 Matcher.new :exist do |
10 match do |actual| |
11 predicates = [:exist?, :exists?].select { |p| actual.respond_to?(p) } |
12 existance_values = predicates.map { |p| actual.send(p, *args) } |
13 uniq_truthy_values = existance_values.map { |v| !!v }.uniq |
14 |
15 case uniq_truthy_values.size |
16 when 0; raise NoMethodError.new("#{actual.inspect} does not respond to either #exist? or #exists?") |
17 when 1; existance_values.first |
18 else raise "#exist? and #exists? returned different values:\n\n" + |
19 " exist?: #{existance_values.first}\n" + |
20 "exists?: #{existance_values.last}" |
21 end |
22 end |
23 end |
24 end |
25 end |
26 end |
Generated on Fri Apr 22 17:22:41 -0700 2011 with rcov 0.9.8