Class ContextState
In: lib/mspec/runner/context.rb
Parent: Object

Holds the state of the describe block that is being evaluated. Every example (i.e. it block) is evaluated in a context, which may include state set up in before :each or before :all blocks.

Methods

Attributes

children  [R] 
examples  [R] 
parent  [R] 
parents  [R] 
state  [R] 
to_s  [R] 

Public Class methods

Public Instance methods

Adds a nested ContextState in a shared ContextState to a containing ContextState.

Normal adoption is from the parent‘s perspective. But adopt is a good verb and it‘s reasonable for the child to adopt the parent as well. In this case, manipulating state from inside the child avoids needlessly exposing the state to manipulate it externally in the dup. (See it_should_behave_like)

Records after(:each) and after(:all) blocks.

Records before(:each) and before(:all) blocks.

Add the ContextState instance child to the list of nested describe blocks.

Evaluates the block and resets the toplevel ContextState to parent.

Returns a description string generated from self and all parents

Removes filtered examples. Returns true if there are examples left to evaluate.

Remove caching when a ContextState is dup‘d for shared specs.

Creates an ExampleState instance for the block and stores it in a list of examples to evaluate unless the example is filtered.

Injects the before/after blocks and examples from the shared describe block into this ContextState instance.

Set the parent (enclosing) ContextState for this state. Creates the parents list.

Returns a list of all after(what) blocks from self and any parents. The list is in reverse order. In other words, the blocks defined in inner describes are in the list before those defined in outer describes, and in a particular describe block those defined later are in the list before those defined earlier.

Returns a list of all before(what) blocks from self and any parents.

Evaluates the examples in a ContextState. Invokes the MSpec events for :enter, :before, :after, :leave.

Evaluates each block in blocks using the +MSpec.protect+ method so that exceptions are handled and tallied. Returns true and does NOT evaluate any blocks if check is true and MSpec.mode?(:pretend) is true.

Returns true if this is a shared ContextState. Essentially, when created with: describe "Something", :shared => true { … }

[Validate]