Class: Lopata::ScenarioBuilder
- Inherits:
-
Object
- Object
- Lopata::ScenarioBuilder
- Includes:
- ActiveRecord::DSL, FactoryBot::DSL, Role::DSL
- Defined in:
- lib/lopata/scenario_builder.rb
Overview
Context for scenario creation.
Defined Under Namespace
Classes: OptionSet
Defining variants collapse
-
#diagonal(metadata_key, variants) ⇒ Object
Define diagonal for the scenario.
-
#metadata(hash) ⇒ Object
Define additional metadata for the scenario.
-
#option(metadata_key, variants) ⇒ Object
Define option for the scenario.
-
#skip_when(&block) ⇒ Object
Skip scenario for given variants combination.
Defining Steps collapse
-
#action(*steps, &block) ⇒ Object
Define action step.
-
#context(title, **metadata, &block) ⇒ Object
Define group of steps.
-
#it(title, &block) ⇒ Object
Define single validation step.
-
#let(method_name, &block) ⇒ Object
Define runtime method for the scenario.
-
#let!(method_name, &block) ⇒ Object
Define memorized runtime method for the scenario.
-
#setup(*steps, &block) ⇒ Object
Define setup step.
-
#teardown(*steps, &block) ⇒ Object
Define teardown step.
-
#verify(*steps, &block) ⇒ Object
Define verify steps.
Class Method Summary collapse
-
.define(title, metadata = {}, &block) ⇒ Object
Defines one or more scenarios.
Methods included from ActiveRecord::DSL
Methods included from Role::DSL
Class Method Details
.define(title, metadata = {}, &block) ⇒ Object
Defines one or more scenarios.
Given block will be calculated in context of the ScenarioBuilder
23 24 25 26 27 |
# File 'lib/lopata/scenario_builder.rb', line 23 def self.define(title, = {}, &block) builder = new(title, ) builder.instance_exec &block builder.build end |
Instance Method Details
#action(*steps, &block) ⇒ Object
Define action step. Action step is used for emulate user or external system action
212 |
# File 'lib/lopata/scenario_builder.rb', line 212 define_step_method :action |
#context(title, **metadata, &block) ⇒ Object
Define group of steps. The metadata for the group may be overriden Teardown steps within group will be called at the end of the group, not scenario
256 |
# File 'lib/lopata/scenario_builder.rb', line 256 define_step_method :context |
#diagonal(metadata_key, variants) ⇒ Object
Define diagonal for the scenario.
The scenario will be generated for all the variants of the diagonal. Each variant of diagonal will be selected for at least one scenario. It may be included in more then one scenario when other diagonal or option has more variants.
109 110 111 |
# File 'lib/lopata/scenario_builder.rb', line 109 def diagonal(, variants) @diagonals << Diagonal.new(, variants) end |
#it(title, &block) ⇒ Object
Define single validation step.
266 |
# File 'lib/lopata/scenario_builder.rb', line 266 define_step_method :it |
#let(method_name, &block) ⇒ Object
The method to be called via #method_missing, so it wont override already defined methods.
Define runtime method for the scenario.
278 279 280 281 282 |
# File 'lib/lopata/scenario_builder.rb', line 278 def let(method_name, &block) steps << Lopata::Step.new(:let) do execution.let(method_name, &block) end end |
#let!(method_name, &block) ⇒ Object
The method to be called via #method_missing, so it wont override already defined methods.
Define memorized runtime method for the scenario.
295 296 297 298 299 |
# File 'lib/lopata/scenario_builder.rb', line 295 def let!(method_name, &block) steps << Lopata::Step.new(:let) do execution.let!(method_name, &block) end end |
#metadata(hash) ⇒ Object
Define additional metadata for the scenario
122 123 124 125 126 |
# File 'lib/lopata/scenario_builder.rb', line 122 def (hash) raise 'metadata expected to be a Hash' unless hash.is_a?(Hash) @common_metadata ||= {} @common_metadata.merge! hash end |
#option(metadata_key, variants) ⇒ Object
Define option for the scenario.
The scenario will be generated for all the options. If more then one option given, the scenarios for all options combinations will be generated.
83 84 85 |
# File 'lib/lopata/scenario_builder.rb', line 83 def option(, variants) @options << Option.new(, variants) end |
#setup(*steps, &block) ⇒ Object
Define setup step. Setup step used for set test data.
189 |
# File 'lib/lopata/scenario_builder.rb', line 189 define_step_method :setup |
#skip_when(&block) ⇒ Object
Skip scenario for given variants combination
140 141 142 |
# File 'lib/lopata/scenario_builder.rb', line 140 def skip_when(&block) @skip_when = block end |
#teardown(*steps, &block) ⇒ Object
Define teardown step. Teardown step will be called at the end of scenario running. But it suggested to be decared right after setup or action step which require teardown.
227 |
# File 'lib/lopata/scenario_builder.rb', line 227 define_step_method :teardown |
#verify(*steps, &block) ⇒ Object
Define verify steps. Usually for validation shared steps inclusion
240 |
# File 'lib/lopata/scenario_builder.rb', line 240 define_step_method :verify |