Class: Cucumber::Value::ValueTester

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/value/value_tester.rb

Overview

Author:

  • Colin Humphreys

Instance Method Summary collapse

Constructor Details

#initialize(test) ⇒ ValueTester

Initialises the ValueTester

Parameters:

  • test (String)

    the code block to be executed for the value test



7
8
9
# File 'lib/cucumber/value/value_tester.rb', line 7

def initialize(test)
  @test = test
end

Instance Method Details

#run_testObject

Runs the test block



11
12
13
14
15
16
17
18
# File 'lib/cucumber/value/value_tester.rb', line 11

def run_test
  begin
    @value = eval @test
  rescue Exception => exc
    # TODO: something sensible when tests aren't valid
    @value = false
  end
end

#value?Boolean

Getter for whether the value has been delivered

Returns:

  • (Boolean)

    has the test passed?



21
22
23
# File 'lib/cucumber/value/value_tester.rb', line 21

def value?
  @value
end