Geminstaller C0 Coverage Information - RCov

/Users/woolley/.rvm/gems/ruby-1.8.7-p174@geminstaller/gems/rspec-1.3.0/lib/spec/example/subject.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/example/subject.rb 108 43
75.00%
37.21%

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 Example
3     module Subject
4       module ExampleGroupMethods
5         # Defines an explicit subject for an example group which can then be the
6         # implicit receiver (through delegation) of calls to +should+.
7         #
8         # == Examples
9         #
10         #   describe CheckingAccount, "with $50" do
11         #     subject { CheckingAccount.new(:amount => 50, :currency => :USD) }
12         #     it { should have_a_balance_of(50, :USD) }
13         #     it { should_not be_overdrawn }
14         #     its(:currency) { should == :USD }
15         #   end
16         #
17         # See +ExampleMethods#should+ for more information about this approach.
18         def subject(&block)
19           block.nil? ?
20             explicit_subject || implicit_subject : @explicit_subject_block = block
21         end
22         
23         def its(attribute, &block)
24           describe(attribute) do
25             define_method(:subject) { super().send(attribute) }
26             it(&block)
27           end
28         end
29 
30         attr_reader :explicit_subject_block # :nodoc:
31 
32       private
33 
34         def explicit_subject
35           group = self
36           while group.respond_to?(:explicit_subject_block)
37             return group.explicit_subject_block if group.explicit_subject_block
38             group = group.superclass
39           end
40         end
41 
42         def implicit_subject
43           (described_class ? lambda {described_class.new} : lambda {description_args.first})
44         end
45       end
46 
47       module ExampleMethods
48 
49         alias_method :__should_for_example_group__,     :should
50         alias_method :__should_not_for_example_group__, :should_not
51 
52         # Returns the subject defined in ExampleGroupMethods#subject. The
53         # subject block is only executed once per example, the result of which
54         # is cached and returned by any subsequent calls to +subject+.
55         #
56         # If a class is passed to +describe+ and no subject is explicitly
57         # declared in the example group, then +subject+ will return a new
58         # instance of that class.
59         #
60         # == Examples
61         #
62         #   # explicit subject defined by the subject method
63         #   describe Person do
64         #     subject { Person.new(:birthdate => 19.years.ago) }
65         #     it "should be eligible to vote" do
66         #       subject.should be_eligible_to_vote
67         #     end
68         #   end
69         #
70         #   # implicit subject => { Person.new }
71         #   describe Person do
72         #     it "should be eligible to vote" do
73         #       subject.should be_eligible_to_vote
74         #     end
75         #   end
76         def subject
77           @subject ||= instance_eval(&self.class.subject)
78         end
79 
80         # When +should+ is called with no explicit receiver, the call is
81         # delegated to the object returned by +subject+. Combined with
82         # an implicit subject (see +subject+), this supports very concise
83         # expressions.
84         #
85         # == Examples
86         #
87         #   describe Person do
88         #     it { should be_eligible_to_vote }
89         #   end
90         def should(matcher=nil, message=nil)
91           self == subject ? self.__should_for_example_group__(matcher) : subject.should(matcher,message)
92         end
93 
94         # Just like +should+, +should_not+ delegates to the subject (implicit or
95         # explicit) of the example group.
96         #
97         # == Examples
98         #
99         #   describe Person do
100         #     it { should_not be_eligible_to_vote }
101         #   end
102         def should_not(matcher=nil, message=nil)
103           self == subject ? self.__should_not_for_example_group__(matcher) : subject.should_not(matcher,message)
104         end
105       end
106     end
107   end
108 end

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