Module: Lucid::InterfaceRb::RbDomain
- Defined in:
- lib/lucid/interface_rb/rb_world.rb
Overview
Defines the basic DSL methods available in all Lucid test definitions.
You can, and probably should, extend this DSL with your own methods that make sense in your own domain.
Constant Summary collapse
- AnsiEscapes =
Gherkin::Formatter::AnsiEscapes
Instance Attribute Summary collapse
- #__lucid_runtime ⇒ Object writeonly
- #__natural_language ⇒ Object writeonly
Instance Method Summary collapse
-
#ask(question, timeout_seconds = 60) ⇒ Object
Pause the tests and ask the operator for input.
-
#doc_string(string_without_triple_quotes, content_type = '', line_offset = 0) ⇒ Object
Create an AST::DocString object.
-
#embed(file, mime_type, label = 'Screenshot') ⇒ Object
Embed an image in the output.
-
#inspect ⇒ Object
Prints the list of modules that are included in the Domain.
-
#pending(message = 'TODO') ⇒ Object
Mark the matched step as pending.
-
#puts(*messages) ⇒ Object
Print a message to the output.
-
#step(name, multiline_argument = nil) ⇒ Object
Run a single Gherkin step.
-
#steps(steps_text) ⇒ Object
Run a matcher of Gherkin.
-
#table(text_or_table, file = nil, line_offset = 0) ⇒ Object
Parse Gherkin into a AST::Table object.
- #to_s ⇒ Object
-
#Transform(arg) ⇒ Object
Call a Transform with a string from another Transform definition.
Instance Attribute Details
#__lucid_runtime=(value) ⇒ Object (writeonly)
21 22 23 |
# File 'lib/lucid/interface_rb/rb_world.rb', line 21 def __lucid_runtime=(value) @__lucid_runtime = value end |
#__natural_language=(value) ⇒ Object (writeonly)
21 22 23 |
# File 'lib/lucid/interface_rb/rb_world.rb', line 21 def __natural_language=(value) @__natural_language = value end |
Instance Method Details
#ask(question, timeout_seconds = 60) ⇒ Object
Pause the tests and ask the operator for input
92 93 94 |
# File 'lib/lucid/interface_rb/rb_world.rb', line 92 def ask(question, timeout_seconds=60) @__lucid_runtime.ask(question, timeout_seconds) end |
#doc_string(string_without_triple_quotes, content_type = '', line_offset = 0) ⇒ Object
Create an AST::DocString object
Useful in conjunction with the #step method, when want to specify a content type.
75 76 77 78 |
# File 'lib/lucid/interface_rb/rb_world.rb', line 75 def doc_string(string_without_triple_quotes, content_type='', line_offset=0) # TODO: rename this method to multiline_string @__lucid_runtime.doc_string(string_without_triple_quotes, content_type, line_offset) end |
#embed(file, mime_type, label = 'Screenshot') ⇒ Object
Embed an image in the output
97 98 99 |
# File 'lib/lucid/interface_rb/rb_world.rb', line 97 def (file, mime_type, label='Screenshot') @__lucid_runtime.(file, mime_type, label) end |
#inspect ⇒ Object
Prints the list of modules that are included in the Domain
116 117 118 119 120 121 122 |
# File 'lib/lucid/interface_rb/rb_world.rb', line 116 def inspect modules = [self.class] (class << self; self; end).instance_eval do modules += included_modules end sprintf("#<%s:0x%x>", modules.join('+'), self.object_id) end |
#pending(message = 'TODO') ⇒ Object
Mark the matched step as pending.
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/lucid/interface_rb/rb_world.rb', line 102 def pending( = 'TODO') if block_given? begin yield rescue Exception raise Pending.new() end raise Pending.new("Expected pending '#{}' to fail. No error was raised. No longer pending?") else raise Pending.new() end end |
#puts(*messages) ⇒ Object
Lucid might surprise you with the behavior of this method. Instead of sending the output directly to STDOUT, Lucid will intercept and cache the message until the current step has finished, and then display it.
If you’d prefer to see the message immediately, call Kernel.puts instead.
Print a message to the output.
87 88 89 |
# File 'lib/lucid/interface_rb/rb_world.rb', line 87 def puts(*) @__lucid_runtime.puts(*) end |
#step(name, multiline_argument = nil) ⇒ Object
Run a single Gherkin step
38 39 40 |
# File 'lib/lucid/interface_rb/rb_world.rb', line 38 def step(name, multiline_argument=nil) @__lucid_runtime.invoke(name, multiline_argument) end |
#steps(steps_text) ⇒ Object
Run a matcher of Gherkin
49 50 51 |
# File 'lib/lucid/interface_rb/rb_world.rb', line 49 def steps(steps_text) @__lucid_runtime.invoke_steps(steps_text, @__natural_language, caller[0]) end |
#table(text_or_table, file = nil, line_offset = 0) ⇒ Object
Parse Gherkin into a AST::Table object.
Useful in conjunction with the #step method.
63 64 65 |
# File 'lib/lucid/interface_rb/rb_world.rb', line 63 def table(text_or_table, file=nil, line_offset=0) @__lucid_runtime.table(text_or_table, file, line_offset) end |
#to_s ⇒ Object
124 125 126 |
# File 'lib/lucid/interface_rb/rb_world.rb', line 124 def to_s inspect end |
#Transform(arg) ⇒ Object
Call a Transform with a string from another Transform definition
15 16 17 18 |
# File 'lib/lucid/interface_rb/rb_world.rb', line 15 def Transform(arg) rb = @__lucid_runtime.load_code_language('rb') rb.execute_transforms([arg]).first end |