Class: ScenarioContext

Inherits:
Object
  • Object
show all
Defined in:
lib/scenario_context.rb,
lib/scenario_context/version.rb,
lib/scenario_context/scenario_proxy.rb

Overview

A class that holds useful debug information from a Scenario or Scenario Outline

Defined Under Namespace

Classes: ScenarioProxy

Constant Summary collapse

VERSION =

The version of the scenario_context gem

'1.0.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scenario) ⇒ ScenarioContext

Returns a new instance of ScenarioContext.



10
11
12
# File 'lib/scenario_context.rb', line 10

def initialize(scenario)
  @scenario = ScenarioProxy.new(scenario)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object (private)

Returns the return value of the method after sending it to @scenario.

Returns:

  • the return value of the method after sending it to @scenario

Raises:

  • (NoMethodError)

    if @scenario could not respond to the missing method



40
41
42
43
44
45
46
47
48
# File 'lib/scenario_context.rb', line 40

def method_missing(method_name, *args, &block)
  if scenario.respond_to?(method_name)
    scenario.send(method_name, *args, &block)
  elsif original_scenario.respond_to?(method_name)
    original_scenario.send(method_name, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#scenarioObject

Returns the value of attribute scenario.



8
9
10
# File 'lib/scenario_context.rb', line 8

def scenario
  @scenario
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns true if the method is available or whether @scenario responds to the method.

Returns:

  • (Boolean)

    true if the method is available or whether @scenario responds to the method



31
32
33
# File 'lib/scenario_context.rb', line 31

def respond_to_missing?(method_name, include_private = false)
  super || scenario.respond_to?(method_name, include_private) || original_scenario.respond_to?(method_name, include_private)
end