Class: RainforestRubyRuntime::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/rainforest_ruby_runtime/test.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, title:, &block) ⇒ Test

Returns a new instance of Test.



5
6
7
8
9
10
# File 'lib/rainforest_ruby_runtime/test.rb', line 5

def initialize(id: , title: , &block)
  @id = id
  @title = title
  @steps = []
  @block = block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



25
26
27
28
29
30
31
# File 'lib/rainforest_ruby_runtime/test.rb', line 25

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

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/rainforest_ruby_runtime/test.rb', line 3

def id
  @id
end

#stepsObject (readonly)

Returns the value of attribute steps.



3
4
5
# File 'lib/rainforest_ruby_runtime/test.rb', line 3

def steps
  @steps
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/rainforest_ruby_runtime/test.rb', line 3

def title
  @title
end

Instance Method Details

#runObject



19
20
21
22
23
# File 'lib/rainforest_ruby_runtime/test.rb', line 19

def run
  extend RSpec::Matchers
  extend Capybara::DSL
  instance_eval &@block
end

#step(**args, &block) ⇒ Object



12
13
14
15
16
17
# File 'lib/rainforest_ruby_runtime/test.rb', line 12

def step(**args, &block)
  step = Step.new(**args, &block)
  @steps << step
  step.run
  step
end