module Rspec::Core::ExampleGroupSubject::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_class.is_a?(Class) ? lambda { described_class.new } : lambda { described_class }
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.nil? ?
  explicit_subject || implicit_subject : @explicit_subject_block = block
end