Class: Screenplay::TestActor
- Inherits:
-
Actor
- Object
- Actor
- Screenplay::TestActor
show all
- Defined in:
- lib/screenplay/actors/test.rb
Instance Attribute Summary
Attributes inherited from Actor
#name
Instance Method Summary
collapse
Methods inherited from Actor
#configure, descendants, #initialize
Instance Method Details
#play(params, input) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/screenplay/actors/test.rb', line 31
def play(params, input)
params.each { | key, values |
values.each { | test, b |
expects = !test.to_s.start_with?('not-')
test = test.to_s[4..-1] unless expects
method = "test_#{test}".to_sym
raise UnknownTestException.new(test) if !respond_to?(method)
a = input.get_value_from_path(key)
raise TestFailedException.new(test, a, b) unless (public_send(method, a, b) == expects)
}
}
return input
end
|
#test_eq(a, b) ⇒ Object
53
54
55
|
# File 'lib/screenplay/actors/test.rb', line 53
def test_eq(a, b)
a === b
end
|
#test_gt(a, b) ⇒ Object
61
62
63
|
# File 'lib/screenplay/actors/test.rb', line 61
def test_gt(a, b)
a > b
end
|
#test_gte(a, b) ⇒ Object
57
58
59
|
# File 'lib/screenplay/actors/test.rb', line 57
def test_gte(a, b)
a >= b
end
|
#test_in(a, b) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/screenplay/actors/test.rb', line 65
def test_in(a, b)
if (b.is_a?(String))
b.index(a) != nil
elsif (b.is_a?(Array))
b.to_a.include?(a)
elsif (b.is_a?(Hash))
b.include?(a.to_sym)
else
raise UnsupportedTypeTestException.new(:in, b)
end
end
|
#test_lt(a, b) ⇒ Object
45
46
47
|
# File 'lib/screenplay/actors/test.rb', line 45
def test_lt(a, b)
a < b
end
|
#test_lte(a, b) ⇒ Object
49
50
51
|
# File 'lib/screenplay/actors/test.rb', line 49
def test_lte(a, b)
a <= b
end
|
#test_regexp(a, b) ⇒ Object
#test_size(a, b) ⇒ Object
77
78
79
80
81
82
83
|
# File 'lib/screenplay/actors/test.rb', line 77
def test_size(a, b)
if (a.respond_to?(:size))
a.size == b
else
raise UnsupportedTypeTestException.new(:size, a)
end
end
|