Class: ExampleState
- Defined in:
- lib/extensions/mspec/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
-
#context ⇒ Object
Returns the value of attribute context.
-
#example ⇒ Object
readonly
Returns the value of attribute example.
-
#it ⇒ Object
readonly
Returns the value of attribute it.
Instance Method Summary collapse
- #describe ⇒ Object
- #description ⇒ Object
- #filtered? ⇒ Boolean
-
#initialize(context, it, example = nil) ⇒ ExampleState
constructor
A new instance of ExampleState.
Constructor Details
#initialize(context, it, example = nil) ⇒ ExampleState
Returns a new instance of ExampleState.
8 9 10 11 12 |
# File 'lib/extensions/mspec/mspec/runner/example.rb', line 8 def initialize(context, it, example=nil) @context = context @it = it @example = example end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
6 7 8 |
# File 'lib/extensions/mspec/mspec/runner/example.rb', line 6 def context @context end |
#example ⇒ Object (readonly)
Returns the value of attribute example.
6 7 8 |
# File 'lib/extensions/mspec/mspec/runner/example.rb', line 6 def example @example end |
#it ⇒ Object (readonly)
Returns the value of attribute it.
6 7 8 |
# File 'lib/extensions/mspec/mspec/runner/example.rb', line 6 def it @it end |
Instance Method Details
#describe ⇒ Object
19 20 21 |
# File 'lib/extensions/mspec/mspec/runner/example.rb', line 19 def describe @context.description end |
#description ⇒ Object
23 24 25 |
# File 'lib/extensions/mspec/mspec/runner/example.rb', line 23 def description @description ||= "#{describe} #{@it}" end |
#filtered? ⇒ Boolean
27 28 29 30 31 32 33 |
# File 'lib/extensions/mspec/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 |