Methods

Class/Module Index [+]

Quicksearch

Spec::Example::Subject::ExampleGroupMethods

Public Instance Methods

its(attribute, &block) click to toggle source
# File lib/spec/example/subject.rb, line 23
def its(attribute, &block)
  describe(attribute) do
    define_method(:subject) { super().send(attribute) }
    it(&block)
  end
end
subject(&block) click to toggle source

Defines an explicit subject for an example group which can then be the implicit receiver (through delegation) of calls to should.

Examples

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

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

# File lib/spec/example/subject.rb, line 18
def subject(&block)
  block.nil? ?
    explicit_subject || implicit_subject : @explicit_subject_block = block
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.