module Spec::Example::Subject::ExampleMethods
def should(matcher=nil)
it { should be_eligible_to_vote }
describe Person do
== Examples
expressions.
an implicit subject (see +subject+), this supports very concise
delegated to the object returned by +subject+. Combined with
When +should+ is called with no explicit receiver, the call is
def should(matcher=nil) if matcher subject.should(matcher) else subject.should end end
def should_not(matcher=nil)
it { should_not be_eligible_to_vote }
describe Person do
== Examples
explicit) of the example group.
Just like +should+, +should_not+ delegates to the subject (implicit or
def should_not(matcher=nil) if matcher subject.should_not(matcher) else subject.should_not end end
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
is cached and returned by any subsequent calls to +subject+.
subject block is only executed once per example, the result of which
Returns the subject defined in ExampleGroupMethods#subject. The
def subject @subject ||= instance_eval(&self.class.subject) end