Module: Cucumber::Glue::Dsl

Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb

Overview

This module provides the methods the DSL you can use to define steps, hooks, transforms etc.

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.rb_language=(value) ⇒ Object (writeonly)

Sets the attribute rb_language

Parameters:

  • value

    the value to set the attribute rb_language to.



12
13
14
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 12

def rb_language=(value)
  @rb_language = value
end

Class Method Details

.alias_adverb(adverb) ⇒ Object



14
15
16
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 14

def alias_adverb(adverb)
  alias_method adverb, :register_rb_step_definition
end

.build_rb_world_factory(world_modules, namespaced_world_modules, proc) ⇒ Object



18
19
20
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 18

def build_rb_world_factory(world_modules, namespaced_world_modules, proc)
  @rb_language.build_rb_world_factory(world_modules, namespaced_world_modules, proc)
end

.define_parameter_type(parameter_type) ⇒ Object



26
27
28
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 26

def define_parameter_type(parameter_type)
  @rb_language.define_parameter_type(parameter_type)
end

.register_rb_hook(phase, tag_names, proc, name: nil) ⇒ Object



22
23
24
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 22

def register_rb_hook(phase, tag_names, proc, name: nil)
  @rb_language.register_rb_hook(phase, tag_names, proc, name: name)
end

.register_rb_step_definition(regexp, proc_or_sym, options = {}) ⇒ Object



30
31
32
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 30

def register_rb_step_definition(regexp, proc_or_sym, options = {})
  @rb_language.register_rb_step_definition(regexp, proc_or_sym, options)
end

Instance Method Details

#After(*tag_expressions, name: nil, &proc) ⇒ Object

Registers a proc that will run after each Scenario. You can register as many as you want (typically from ruby scripts under support/hooks.rb).



71
72
73
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 71

def After(*tag_expressions, name: nil, &proc)
  Dsl.register_rb_hook('after', tag_expressions, proc, name: name)
end

#AfterAll(name: nil, &proc) ⇒ Object

Registers a proc that will run after the execution of the scenarios. Use it for your final clean-ups



123
124
125
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 123

def AfterAll(name: nil, &proc)
  Dsl.register_rb_hook('after_all', [], proc, name: name)
end

#AfterStep(*tag_expressions, name: nil, &proc) ⇒ Object

Registers a proc that will run after each Step. You can register as as you want (typically from ruby scripts under support/hooks.rb).



86
87
88
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 86

def AfterStep(*tag_expressions, name: nil, &proc)
  Dsl.register_rb_hook('after_step', tag_expressions, proc, name: name)
end

#Around(*tag_expressions, name: nil, &proc) ⇒ Object

Registers a proc that will be wrapped around each scenario. The proc should accept two arguments: two arguments: the scenario and a “block” argument (but passed as a regular argument, since blocks cannot accept blocks in 1.8), on which it should call the .call method. You can register as many as you want (typically from ruby scripts under support/hooks.rb).



80
81
82
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 80

def Around(*tag_expressions, name: nil, &proc)
  Dsl.register_rb_hook('around', tag_expressions, proc, name: name)
end

#Before(*tag_expressions, name: nil, &proc) ⇒ Object

Registers a proc that will run before each Scenario. You can register as many as you want (typically from ruby scripts under support/hooks.rb).



65
66
67
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 65

def Before(*tag_expressions, name: nil, &proc)
  Dsl.register_rb_hook('before', tag_expressions, proc, name: name)
end

#BeforeAll(name: nil, &proc) ⇒ Object

Registers a proc that will run before the execution of the scenarios. Use it for your final set-ups



117
118
119
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 117

def BeforeAll(name: nil, &proc)
  Dsl.register_rb_hook('before_all', [], proc, name: name)
end

#if_nil(value, default) ⇒ Object



106
107
108
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 106

def if_nil(value, default)
  value.nil? ? default : value
end

#InstallPlugin(name: nil, &proc) ⇒ Object

Registers a proc that will run after Cucumber is configured in order to install an external plugin.



111
112
113
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 111

def InstallPlugin(name: nil, &proc)
  Dsl.register_rb_hook('install_plugin', [], proc, name: name)
end

#ParameterType(options) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 90

def ParameterType(options)
  type = options[:type] || Object
  use_for_snippets = if_nil(options[:use_for_snippets], true)
  prefer_for_regexp_match = if_nil(options[:prefer_for_regexp_match], false)

  parameter_type = CucumberExpressions::ParameterType.new(
    options[:name],
    options[:regexp],
    type,
    options[:transformer],
    use_for_snippets,
    prefer_for_regexp_match
  )
  Dsl.define_parameter_type(parameter_type)
end

#register_rb_step_definition(regexp, symbol = nil, options = {}, &proc) ⇒ Object

Registers a new Ruby StepDefinition. This method is aliased to Given, When and Then, and also to the i18n translations whenever a feature of a new language is loaded.

If provided, the symbol is sent to the World object as defined by #World. A new World object is created for each scenario and is shared across step definitions within that scenario. If the options hash contains an :on key, the value for this is assumed to be a proc. This proc will be executed in the context of the World object and then sent the symbol.

If no symbol if provided then the &proc gets executed in the context of the World object.



142
143
144
145
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 142

def register_rb_step_definition(regexp, symbol = nil, options = {}, &proc)
  proc_or_sym = symbol || proc
  Dsl.register_rb_step_definition(regexp, proc_or_sym, options)
end

#World(*world_modules, **namespaced_world_modules, &proc) ⇒ Object

Registers any number of world_modules (Ruby Modules) and/or a Proc. The proc will be executed once before each scenario to create an Object that the scenario’s steps will run within. Any world_modules will be mixed into this Object (via Object#extend).

By default the world modules are added to a global namespace. It is possible to create a namespaced World by using an hash, where the symbols are the namespaces.

This method is typically called from one or more Ruby scripts under features/support. You can call this method as many times as you like (to register more modules), but if you try to register more than one Proc you will get an error.

Cucumber will not yield anything to the proc. Examples:

World do
  MyClass.new
end

World(MyModule)

World(my_module: MyModule)


59
60
61
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/dsl.rb', line 59

def World(*world_modules, **namespaced_world_modules, &proc)
  Dsl.build_rb_world_factory(world_modules, namespaced_world_modules, proc)
end