Class: ExampleState

Inherits:
Object show all
Defined in:
lib/mspec/runner/example.rb

Overview

Holds some of the state of the example (i.e. it block) that is being evaluated. See also ContextState.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, it, example = nil) ⇒ ExampleState

Returns a new instance of ExampleState


8
9
10
11
12
# File 'lib/mspec/runner/example.rb', line 8

def initialize(context, it, example=nil)
  @context  = context
  @it       = it
  @example  = example
end

Instance Attribute Details

#contextObject

Returns the value of attribute context


6
7
8
# File 'lib/mspec/runner/example.rb', line 6

def context
  @context
end

#exampleObject (readonly)

Returns the value of attribute example


6
7
8
# File 'lib/mspec/runner/example.rb', line 6

def example
  @example
end

#itObject (readonly)

Returns the value of attribute it


6
7
8
# File 'lib/mspec/runner/example.rb', line 6

def it
  @it
end

Instance Method Details

#describeObject


19
20
21
# File 'lib/mspec/runner/example.rb', line 19

def describe
  @context.description
end

#descriptionObject


23
24
25
# File 'lib/mspec/runner/example.rb', line 23

def description
  @description ||= "#{describe} #{@it}"
end

#filtered?Boolean

Returns:

  • (Boolean)

27
28
29
30
31
32
33
# File 'lib/mspec/runner/example.rb', line 27

def filtered?
  incl = MSpec.retrieve(:include) || []
  excl = MSpec.retrieve(:exclude) || []
  included   = incl.empty? || incl.any? { |f| f === description }
  included &&= excl.empty? || !excl.any? { |f| f === description }
  not included
end