Class: Gurke::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/gurke/configuration.rb

Defined Under Namespace

Classes: Hook, HookSet, Inclusion

Instance Method Summary collapse

Instance Method Details

#after(action = :scenario, opts = nil) { ... } ⇒ Object

Define a after filter running after given action.

Examples:

Gurke.after(:step) do
  puts step.description
end

Parameters:

  • action (Symbol) (defaults to: :scenario)

    A defined action like ‘:feature`, `:scenario` or `:step`.

Yields:

  • After any matching action is executed.



42
43
44
45
46
# File 'lib/gurke/configuration.rb', line 42

def after(action = :scenario, opts = nil, &block)
  raise ArgumentError.new "Unknown hook: #{action}" unless hooks[action]

  hooks[action].append :after, Hook.new(opts, &block)
end

#around(action = :scenario, opts = nil, &block) ⇒ Object



24
25
26
27
28
# File 'lib/gurke/configuration.rb', line 24

def around(action = :scenario, opts = nil, &block)
  raise ArgumentError.new "Unknown hook: #{action}" unless hooks[action]

  hooks[action].append :around, Hook.new(opts, &block)
end

#before(action = :scenario, opts = nil) { ... } ⇒ Object

Define a before filter running before given action.

Examples:

Gurke.before(:step) do
  puts step.description
end

Parameters:

  • action (Symbol) (defaults to: :scenario)

    A defined action like ‘:feature`, `:scenario` or `:step`.

Yields:

  • Before any matching action is executed.



18
19
20
21
22
# File 'lib/gurke/configuration.rb', line 18

def before(action = :scenario, opts = nil, &block)
  raise ArgumentError.new "Unknown hook: #{action}" unless hooks[action]

  hooks[action].append :before, Hook.new(opts, &block)
end

#hooksObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/gurke/configuration.rb', line 67

def hooks
  @hooks ||= begin
    hooks = {
      features: HookSet.new,
      feature: HookSet.new,
      scenario: HookSet.new,
      step: HookSet.new,
      system: HookSet.new
    }

    hooks.merge! each: hooks[:scenario]
    hooks
  end
end

#include(mod, opts = {}) ⇒ Object

Include given module into all or specific features or scenarios.

Examples:

Gurke.include(MyTestMethods)

Parameters:

  • mod (Module)

    Module to include.

  • opts (Hash) (defaults to: {})

    Options.



57
58
59
# File 'lib/gurke/configuration.rb', line 57

def include(mod, opts = {})
  inclusions << Inclusion.new(mod, opts)
end

#inclusionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



62
63
64
# File 'lib/gurke/configuration.rb', line 62

def inclusions
  @inclusions ||= []
end