Class Index [+]

Quicksearch

Spec::Example::Subject::ExampleGroupMethods

Public Instance Methods

its(attribute, &block) click to toggle source
    # File lib/spec/example/subject.rb, line 23
23:         def its(attribute, &block)
24:           describe(attribute) do
25:             define_method(:subject) { super().send(attribute) }
26:             it(&block)
27:           end
28:         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
18:         def subject(&block)
19:           block.nil? ?
20:             explicit_subject || implicit_subject : @explicit_subject_block = block
21:         end

Private Instance Methods

explicit_subject() click to toggle source
    # File lib/spec/example/subject.rb, line 34
34:         def explicit_subject
35:           group = self
36:           while group.respond_to?(:explicit_subject_block)
37:             return group.explicit_subject_block if group.explicit_subject_block
38:             group = group.superclass
39:           end
40:         end
implicit_subject() click to toggle source
    # File lib/spec/example/subject.rb, line 42
42:         def implicit_subject
43:           (described_class ? lambda {described_class.new} : lambda {description_args.first})
44:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.