Module: Synthra::Scenarios::RSpecHelpers
- Defined in:
- lib/synthra/scenarios.rb
Overview
RSpec integration
Instance Method Summary collapse
-
#include_scenario(scenario_name, **options) ⇒ Object
Include a scenario in a test.
-
#use_scenario(scenario_name, **options) ⇒ Object
Use scenario data in a before block.
Instance Method Details
#include_scenario(scenario_name, **options) ⇒ Object
Include a scenario in a test
356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/synthra/scenarios.rb', line 356 def include_scenario(scenario_name, **) scenario = Scenarios[scenario_name] raise ArgumentError, "Unknown scenario: #{scenario_name}" unless scenario let(:scenario_context) { scenario.build(**) } # Define let helpers for each fixture scenario.fixtures.keys.each do |fixture_name| let(fixture_name) { scenario_context[fixture_name] } end end |
#use_scenario(scenario_name, **options) ⇒ Object
Use scenario data in a before block
369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/synthra/scenarios.rb', line 369 def use_scenario(scenario_name, **) before(:each) do scenario = Scenarios[scenario_name] @scenario_context = scenario.build(**) # Make fixtures available as instance variables @scenario_context.data.each do |name, value| instance_variable_set("@#{name}", value) end end end |