Module: Lucid::InterfaceRb::RbLucid

Defined in:
lib/lucid/interface_rb/rb_lucid.rb

Overview

It is necessary for the RbLucid module to be mixed in to the top level object. This is what allows TDL test definitions and hooks to be resolved as valid methods.

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.



8
9
10
# File 'lib/lucid/interface_rb/rb_lucid.rb', line 8

def rb_language=(value)
  @rb_language = value
end

Class Method Details

.alias_adverb(adverb) ⇒ Object



10
11
12
# File 'lib/lucid/interface_rb/rb_lucid.rb', line 10

def alias_adverb(adverb)
  alias_method adverb, :register_rb_step_definition
end

.build_rb_world_factory(domain_modules, proc) ⇒ Object



14
15
16
# File 'lib/lucid/interface_rb/rb_lucid.rb', line 14

def build_rb_world_factory(domain_modules, proc)
  @rb_language.build_rb_world_factory(domain_modules, proc)
end

.register_rb_hook(phase, tag_names, proc) ⇒ Object



18
19
20
# File 'lib/lucid/interface_rb/rb_lucid.rb', line 18

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

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



26
27
28
# File 'lib/lucid/interface_rb/rb_lucid.rb', line 26

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

.register_rb_transform(regexp, proc) ⇒ Object



22
23
24
# File 'lib/lucid/interface_rb/rb_lucid.rb', line 22

def register_rb_transform(regexp, proc)
  @rb_language.register_rb_transform(regexp, proc)
end

Instance Method Details

#After(*tag_expressions, &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).



63
64
65
# File 'lib/lucid/interface_rb/rb_lucid.rb', line 63

def After(*tag_expressions, &proc)
  RbLucid.register_rb_hook('after', tag_expressions, proc)
end

#AfterConfiguration(&proc) ⇒ Object

Registers a proc that will run after Lucid is configured. You can register as as you want (typically from ruby scripts under support/hooks.rb). TODO: Deprecate this



94
95
96
# File 'lib/lucid/interface_rb/rb_lucid.rb', line 94

def AfterConfiguration(&proc)
  RbLucid.register_rb_hook('after_configuration', [], proc)
end

#AfterStep(*tag_expressions, &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).



78
79
80
# File 'lib/lucid/interface_rb/rb_lucid.rb', line 78

def AfterStep(*tag_expressions, &proc)
  RbLucid.register_rb_hook('after_step', tag_expressions, proc)
end

#Around(*tag_expressions, &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).



72
73
74
# File 'lib/lucid/interface_rb/rb_lucid.rb', line 72

def Around(*tag_expressions, &proc)
  RbLucid.register_rb_hook('around', tag_expressions, proc)
end

#Before(*tag_expressions, &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).



57
58
59
# File 'lib/lucid/interface_rb/rb_lucid.rb', line 57

def Before(*tag_expressions, &proc)
  RbLucid.register_rb_hook('before', tag_expressions, proc)
end

#Domain(*domain_modules, &proc) ⇒ Object Also known as: World

Registers any number of domain_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 domain_modules will be mixed into this Object (via Object#extend).

This method is typically called from one or more Ruby scripts under common/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.

Lucid will not yield anything to the proc. Examples:

Domain do
  MyClass.new
end

Domain(MyModule)


49
50
51
# File 'lib/lucid/interface_rb/rb_lucid.rb', line 49

def Domain(*domain_modules, &proc)
  RbLucid.build_rb_world_factory(domain_modules, proc)
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 Domain object as defined by #Domain. A new Domain 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 Domain object and then sent the symbol.

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



113
114
115
116
# File 'lib/lucid/interface_rb/rb_lucid.rb', line 113

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

#Transform(regexp, &proc) ⇒ Object

Registers a proc that will be called with a step definition argument if it matches the pattern passed as the first argument to Transform. Alternatively, if the pattern contains captures then they will be yielded as arguments to the provided proc. The return value of the proc is consequently yielded to the step definition.



87
88
89
# File 'lib/lucid/interface_rb/rb_lucid.rb', line 87

def Transform(regexp, &proc)
  RbLucid.register_rb_transform(regexp, proc)
end