Class: RainforestRubyRuntime::DSL

Inherits:
Object
  • Object
show all
Includes:
Capybara::DSL, RSpec::Matchers
Defined in:
lib/rainforest_ruby_runtime/dsl.rb

Instance Method Summary collapse

Constructor Details

#initialize(callback:) ⇒ DSL

Returns a new instance of DSL.



6
7
8
# File 'lib/rainforest_ruby_runtime/dsl.rb', line 6

def initialize(callback: )
  @callback = callback
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/rainforest_ruby_runtime/dsl.rb', line 27

def method_missing(name, *args, &block)
  if Variables.scope_registry.has_variable?(name)
    Variables.scope_registry[name]
  else
    super
  end
end

Instance Method Details

#define_variable_scope(name, &block) ⇒ Object



18
19
20
21
# File 'lib/rainforest_ruby_runtime/dsl.rb', line 18

def define_variable_scope(name, &block)
  scope = Variables::Scope.new(name, &block)
  Variables.scope_registry.register(scope)
end

#run_code(code) ⇒ Object



23
24
25
# File 'lib/rainforest_ruby_runtime/dsl.rb', line 23

def run_code(code)
  eval(code)
end

#step(options, &block) ⇒ Object



14
15
16
# File 'lib/rainforest_ruby_runtime/dsl.rb', line 14

def step(options, &block)
  RainforestRubyRuntime::Step.new(options.merge(callback: @callback), &block).tap(&:run)
end

#test(id:, title:, &block) ⇒ Object



10
11
12
# File 'lib/rainforest_ruby_runtime/dsl.rb', line 10

def test(id: , title: , &block)
  RainforestRubyRuntime::Test.new(id: id, title: title, callback: @callback, &block)
end