module Rspec::Core::Subject::ClassMethods

def explicit_subject

def explicit_subject
  group = self
  while group.respond_to?(:explicit_subject_block)
    return group.explicit_subject_block if group.explicit_subject_block
    group = group.superclass
  end
end

def implicit_subject

def implicit_subject
  described = describes || description
  Class === described ? proc { described.new } : proc { described }
end

def subject(&block)

See +ExampleMethods#should+ for more information about this approach.

end
it { should_not be_overdrawn }
it { should have_a_balance_of(50, :USD) }
subject { CheckingAccount.new(:amount => 50, :currency => :USD) }
describe CheckingAccount, "with $50" do

== Examples

implicit receiver (through delegation) of calls to +should+.
Defines an explicit subject for an example group which can then be the
def subject(&block)
  block ? @explicit_subject_block = block : explicit_subject || implicit_subject
end