Module: Spinach::DSL::ClassMethods
- Defined in:
- lib/spinach/dsl.rb
Overview
Class methods to extend the host class.
Instance Attribute Summary collapse
-
#feature_name ⇒ Object
readonly
The feature name.
Instance Method Summary collapse
-
#after(&block) ⇒ Object
Defines a after hook for each scenario.
-
#before(&block) ⇒ Object
Defines a before hook for each scenario.
-
#feature(name) ⇒ Object
Sets the feature name.
-
#step(step, &block) ⇒ Object
(also: #Given, #When, #Then, #And, #But)
Defines an action to perform given a particular step literal.
-
#steps ⇒ Object
Get the list of step names in this class.
Instance Attribute Details
#feature_name ⇒ Object (readonly)
The feature name.
21 22 23 |
# File 'lib/spinach/dsl.rb', line 21 def feature_name @feature_name end |
Instance Method Details
#after(&block) ⇒ Object
Defines a after hook for each scenario. The scope is limited only to the current step class (thus the current feature).
When a scenario is executed, the after each block will be run after any steps
User can define multiple after blocks throughout the class hierarchy and they are chained through the inheritance chain when executing.
127 128 129 |
# File 'lib/spinach/dsl.rb', line 127 def after(&block) define_before_or_after_method_with_block(:after, &block) end |
#before(&block) ⇒ Object
Defines a before hook for each scenario. The scope is limited only to the current step class (thus the current feature).
When a scenario is executed, the before each block will be run first before any steps
User can define multiple before blocks throughout the class hierarchy and they are chained through the inheritance chain when executing
96 97 98 |
# File 'lib/spinach/dsl.rb', line 96 def before(&block) define_before_or_after_method_with_block(:before, &block) end |
#feature(name) ⇒ Object
Sets the feature name.
142 143 144 |
# File 'lib/spinach/dsl.rb', line 142 def feature(name) @feature_name = name end |
#step(step, &block) ⇒ Object Also known as: Given, When, Then, And, But
Defines an action to perform given a particular step literal.
53 54 55 56 57 58 59 60 |
# File 'lib/spinach/dsl.rb', line 53 def step(step, &block) method_body = if block_given? then block else lambda { pending "step not implemented" } end define_method(Spinach::Support.underscore(step), &method_body) steps << step end |
#steps ⇒ Object
Get the list of step names in this class
147 148 149 |
# File 'lib/spinach/dsl.rb', line 147 def steps @steps ||= [] end |