module RSpec::Core::Subject::InstanceMethods
def subject
end
subject.should be_eligible_to_vote
it "should be eligible to vote" do
describe Person do
# implicit subject => { Person.new }
end
end
subject.should be_eligible_to_vote
it "should be eligible to vote" do
subject { Person.new(:birthdate => 19.years.ago) }
describe Person do
# explicit subject defined by the subject method
== Examples
instance of that class.
declared in the example group, then +subject+ will return a new
If a class is passed to +describe+ and no subject is explicitly
returned by any subsequent calls to +subject+.
only executed once per example, the result of which is cached and
Returns the subject defined by the example group. The subject block is
def subject if defined?(@original_subject) @original_subject else @original_subject = instance_eval(&self.class.subject) end end