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
44
|
# 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)
raise UnknownInputKeyException.new(test, key) unless input.include?(key.to_sym)
a = input[key.to_sym]
raise TestFailedException.new(test, a, b) unless (public_send(method, a, b) == expects)
}
}
return input
end
|
#test_eq(a, b) ⇒ Object
54
55
56
|
# File 'lib/screenplay/actors/test.rb', line 54
def test_eq(a, b)
a === b
end
|
#test_gt(a, b) ⇒ Object
62
63
64
|
# File 'lib/screenplay/actors/test.rb', line 62
def test_gt(a, b)
a > b
end
|
#test_gte(a, b) ⇒ Object
58
59
60
|
# File 'lib/screenplay/actors/test.rb', line 58
def test_gte(a, b)
a >= b
end
|
#test_in(a, b) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/screenplay/actors/test.rb', line 66
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
46
47
48
|
# File 'lib/screenplay/actors/test.rb', line 46
def test_lt(a, b)
a < b
end
|
#test_lte(a, b) ⇒ Object
50
51
52
|
# File 'lib/screenplay/actors/test.rb', line 50
def test_lte(a, b)
a <= b
end
|
#test_regexp(a, b) ⇒ Object
#test_size(a, b) ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/screenplay/actors/test.rb', line 78
def test_size(a, b)
if (a.respond_to?(:size))
a.size == b
else
raise UnsupportedTypeTestException.new(:size, a)
end
end
|