Class: Spinach::Hooks

Inherits:
Object
  • Object
show all
Includes:
Hookable
Defined in:
lib/spinach/hooks.rb

Overview

Spinach’s hooks is a subscription mechanism to allow developers to define certain callbacks given several Spinach signals, like running a feature, executing a particular step and such.

Instance Method Summary collapse

Methods included from Hookable

included

Instance Method Details

#on_tag(tag) ⇒ Object

Runs before running a scenario with a particular tag

Examples:

Spinach.hooks.on_tag('javascript') do
  # change capybara driver
end

Parameters:

  • tag (String)

    the tag to match



168
169
170
171
172
173
174
# File 'lib/spinach/hooks.rb', line 168

def on_tag(tag)
  before_scenario do |scenario, step_definitions|
    tags = scenario.tags
    next unless tags.any?
    yield(scenario, step_definitions) if tags.include? tag.to_s
  end
end