Module Spec::Example::ExampleGroupMethods
In: lib/spec/example/example_group_methods.rb

Methods

Included Modules

Spec::Example::BeforeAndAfterHooks Spec::Adapters::MockFramework

Classes and Modules

Class Spec::Example::ExampleGroupMethods::ExampleGroupHierarchy

External Aliases

description_options -> options

Attributes

description_options  [R] 
matcher_class  [RW] 
spec_path  [R] 

Public Class methods

Public Instance methods

Provides the backtrace up to where this example_group was declared.

context(*args, &example_group_block)

Alias for describe

Makes the describe/it syntax available from a class. For example:

  class StackSpec < Spec::ExampleGroup
    describe Stack, "with no elements"

    before
      @stack = Stack.new
    end

    it "should raise on pop" do
      lambda{ @stack.pop }.should raise_error
    end
  end

Creates an instance of the current example group class and adds it to a collection of examples of the current example group.

it(description=nil, options={}, &implementation)

Alias for example

Use this to pull in examples from shared example groups.

Dynamically generates a custom matcher that will match a predicate on your class. RSpec provides a couple of these out of the box:

  exist (for state expectations)
    File.should exist("path/to/file")

  an_instance_of (for mock argument constraints)
    mock.should_receive(:message).with(an_instance_of(String))

Examples

  class Fish
    def can_swim?
      true
    end
  end

  describe Fish do
    predicate_matchers[:swim] = :can_swim?
    it "should swim" do
      Fish.new.should swim
    end
  end
specify(description=nil, options={}, &implementation)

Alias for example

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}
  end

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

Use this to temporarily disable an example.

xit(description=nil, opts={}, &block)

Alias for xexample

xspecify(description=nil, opts={}, &block)

Alias for xexample

[Validate]