predicate 2.8.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -0
  3. data/lib/predicate/asserter.rb +1 -1
  4. data/lib/predicate/nodes/and.rb +22 -4
  5. data/lib/predicate/nodes/empty.rb +6 -0
  6. data/lib/predicate/nodes/eq.rb +4 -0
  7. data/lib/predicate/nodes/expr.rb +4 -0
  8. data/lib/predicate/nodes/gt.rb +6 -0
  9. data/lib/predicate/nodes/gte.rb +6 -0
  10. data/lib/predicate/nodes/in.rb +12 -0
  11. data/lib/predicate/nodes/lt.rb +6 -0
  12. data/lib/predicate/nodes/lte.rb +6 -0
  13. data/lib/predicate/nodes/neq.rb +11 -0
  14. data/lib/predicate/nodes/tautology.rb +4 -0
  15. data/lib/predicate/version.rb +1 -1
  16. data/lib/predicate.rb +16 -2
  17. data/spec/factory/shared/a_comparison_factory_method.rb +12 -4
  18. data/spec/factory/shared/a_predicate_ast_node.rb +11 -5
  19. data/spec/factory/test_${op_name}.rb.jeny +3 -1
  20. data/spec/factory/test_and.rb +6 -2
  21. data/spec/factory/test_comp.rb +27 -9
  22. data/spec/factory/test_contradiction.rb +3 -1
  23. data/spec/factory/test_empty.rb +3 -1
  24. data/spec/factory/test_factor_predicate.rb +21 -7
  25. data/spec/factory/test_from_hash.rb +21 -7
  26. data/spec/factory/test_has_size.rb +3 -1
  27. data/spec/factory/test_identifier.rb +6 -2
  28. data/spec/factory/test_literal.rb +6 -2
  29. data/spec/factory/test_match.rb +12 -4
  30. data/spec/factory/test_native.rb +6 -2
  31. data/spec/factory/test_not.rb +6 -2
  32. data/spec/factory/test_or.rb +6 -2
  33. data/spec/factory/test_qualified_identifier.rb +6 -2
  34. data/spec/factory/test_set_ops.rb +6 -2
  35. data/spec/factory/test_tautology.rb +3 -1
  36. data/spec/factory/test_var.rb +12 -4
  37. data/spec/grammar/test_match.rb +19 -19
  38. data/spec/grammar/test_sexpr.rb +49 -17
  39. data/spec/nodes/and/test_and_split.rb +30 -10
  40. data/spec/nodes/dyadic_comp/test_and_split.rb +18 -8
  41. data/spec/nodes/eq/test_and.rb +12 -4
  42. data/spec/nodes/identifier/test_and_split.rb +6 -2
  43. data/spec/nodes/identifier/test_free_variables.rb +3 -1
  44. data/spec/nodes/identifier/test_name.rb +3 -1
  45. data/spec/nodes/in/test_and.rb +18 -6
  46. data/spec/nodes/nadic_bool/test_free_variables.rb +3 -1
  47. data/spec/nodes/or/test_and_split.rb +6 -2
  48. data/spec/nodes/qualified_identifier/test_and_split.rb +6 -2
  49. data/spec/nodes/qualified_identifier/test_free_variables.rb +3 -1
  50. data/spec/nodes/qualified_identifier/test_name.rb +3 -1
  51. data/spec/nodes/qualified_identifier/test_qualifier.rb +3 -1
  52. data/spec/predicate/test_and_split.rb +48 -16
  53. data/spec/predicate/test_assert!.rb +210 -0
  54. data/spec/predicate/test_attr_split.rb +36 -12
  55. data/spec/predicate/test_bool_and.rb +7 -3
  56. data/spec/predicate/test_bool_not.rb +30 -10
  57. data/spec/predicate/test_bool_or.rb +7 -3
  58. data/spec/predicate/test_coerce.rb +19 -17
  59. data/spec/predicate/test_constants.rb +78 -26
  60. data/spec/predicate/test_free_variables.rb +3 -1
  61. data/spec/predicate/test_hash_and_equal.rb +7 -3
  62. data/spec/predicate/test_qualify.rb +8 -6
  63. data/spec/predicate/test_rename.rb +21 -11
  64. data/spec/sequel/test_to_sequel.rb +0 -1
  65. data/spec/shared/a_predicate.rb +8 -8
  66. data/spec/spec_helper.rb +1 -0
  67. data/spec/test_readme.rb +1 -1
  68. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b905f4aeb37f046ccef6ac9b7afc674f19f3a91f865be488354daecc8ef28f1
4
- data.tar.gz: d205d1b1e789b2f549ccfe6181f7dfc66a7a650346050c1497521000e243f85f
3
+ metadata.gz: 571d712e35bc8c4144014e76e3827614fdf78191f944a10ce7a1f8f5595886de
4
+ data.tar.gz: c7919717e71c0a23a4c0869e8e0fa384c5e6b8e0db9af5d87ef7c9c89fa8f006
5
5
  SHA512:
6
- metadata.gz: a9ec299aaa242f521d53042df037536e618e00cceebe612c56d083eb3ea62ae7175c9dcfefe45b9dcf52df3b22c4a594a6c1456047a807a924ae4fb0029a60c4
7
- data.tar.gz: c3f88782791b4fbb0d645be5d24a7bfb54b4bddc7128b30b84e60c2fc66f9bb9fa4407620dcbed6f12cb8773fb112cf223ab38cbc96a43fd8c15c96ba66f0e9d
6
+ metadata.gz: d511b557d1b8d05cd4f56064977ba7189faaf37ab33562962a75027ab57454eae11063f9d5444c4a938b804cc5ec3316fe2e5aa39cad7ae33dafcfdd91dc6e4d
7
+ data.tar.gz: cd1ddf3e4e99abb752c940db00a0627f8be5a6e39556b5c37022f884a8457bcfd75cf27d053639887f8cd5da4125ca86926670f6bc3579a38c3563a6e4e5e02c
data/README.md CHANGED
@@ -16,6 +16,9 @@ p.evaluate(:x => 2, :y => 6)
16
16
 
17
17
  p.evaluate(:x => 2, :y => 3)
18
18
  # => false
19
+
20
+ p.assert!(:x => 2, :y => 3)
21
+ # => Minitest::Assertion("Expected false to be truthy")
19
22
  ```
20
23
 
21
24
  When building complex expressions, you can use the `dsl` method.
@@ -226,6 +229,20 @@ p.evaluate(:x => 2, :y => 6)
226
229
  # => true
227
230
  ```
228
231
 
232
+ ### Assert
233
+
234
+ `Predicate#assert!` takes a takes a Hash mapping each free variable to a value,
235
+ and raises a Minitest::AssertionError if the predicate evaluates to false.
236
+ A best effort is made to provide readable error messages on the assertion error.
237
+
238
+ ```ruby
239
+ # Let's build a simple predicate for 'x = 2 and not(y <= 3)'
240
+ p = Predicate.eq(:x, 2) & !Predicate.lte(:y, 3)
241
+
242
+ p.evaluate(:x => 2, :y => 8)
243
+ # => Expected false to be truthy (Minitest::Assertion)
244
+ ```
245
+
229
246
  ### Rename
230
247
 
231
248
  `Predicate#rename` allows renaming variables.
@@ -9,4 +9,4 @@ class Predicate
9
9
  attr_accessor :assertions
10
10
 
11
11
  end # class Asserter
12
- end # class Predicate
12
+ end # class Predicate
@@ -53,14 +53,32 @@ class Predicate
53
53
  sexpr_body.all?{|operand| operand.evaluate(tuple) }
54
54
  end
55
55
 
56
+ def assert!(tuple, asserter = Asserter.new)
57
+ sexpr_body.all?{|operand| operand.assert!(tuple, asserter) }
58
+ end
59
+
56
60
  def to_hash
57
61
  sexpr_body.inject({}) do |p,term|
58
- p.merge(term.to_hash){|k,v1,v2|
59
- super unless v1 == v2
60
- v1
61
- }
62
+ _hash_merge(p, term.to_hash)
62
63
  end
63
64
  end
64
65
 
66
+ def to_hashes
67
+ sexpr_body.inject([{},{}]) do |(pos,neg),term|
68
+ t_pos, t_neg = term.to_hashes
69
+ [
70
+ _hash_merge(pos, t_pos),
71
+ _hash_merge(neg, t_neg)
72
+ ]
73
+ end
74
+ end
75
+
76
+ def _hash_merge(h1, h2)
77
+ h1.merge(h2){|k,v1,v2|
78
+ raise ArgumentError, "Unable to represent #{self} to a Hash" unless v1 == v2
79
+ v1
80
+ }
81
+ end
82
+
65
83
  end
66
84
  end
@@ -10,5 +10,11 @@ class Predicate
10
10
  value.empty?
11
11
  end
12
12
 
13
+ def assert!(tuple, asserter = Asserter.new)
14
+ value = operand.evaluate(tuple)
15
+ asserter.assert_empty(value)
16
+ value
17
+ end
18
+
13
19
  end
14
20
  end
@@ -62,5 +62,9 @@ class Predicate
62
62
  end
63
63
  end
64
64
 
65
+ def to_hashes
66
+ [ to_hash, {} ]
67
+ end
68
+
65
69
  end
66
70
  end
@@ -103,6 +103,10 @@ class Predicate
103
103
  raise ArgumentError, "Unable to represent #{self} to a Hash"
104
104
  end
105
105
 
106
+ def to_hashes
107
+ raise ArgumentError, "Unable to represent #{self} to two Hashes"
108
+ end
109
+
106
110
  def sexpr(arg)
107
111
  Factory.sexpr(arg)
108
112
  end
@@ -10,5 +10,11 @@ class Predicate
10
10
  left.evaluate(tuple) > right.evaluate(tuple)
11
11
  end
12
12
 
13
+ def assert!(tuple, asserter = Asserter.new)
14
+ l, r = left.evaluate(tuple), right.evaluate(tuple)
15
+ asserter.assert_operator(l, :>, r)
16
+ l
17
+ end
18
+
13
19
  end
14
20
  end
@@ -10,5 +10,11 @@ class Predicate
10
10
  left.evaluate(tuple) >= right.evaluate(tuple)
11
11
  end
12
12
 
13
+ def assert!(tuple, asserter = Asserter.new)
14
+ l, r = left.evaluate(tuple), right.evaluate(tuple)
15
+ asserter.assert_operator(l, :>=, r)
16
+ l
17
+ end
18
+
13
19
  end
14
20
  end
@@ -67,6 +67,14 @@ class Predicate
67
67
  values.include?(identifier.evaluate(tuple))
68
68
  end
69
69
 
70
+ def assert!(tuple, asserter = Asserter.new)
71
+ values = right.evaluate(tuple)
72
+ raise UnboundError if values.is_a?(Placeholder)
73
+ value = identifier.evaluate(tuple)
74
+ asserter.assert_includes(values, value)
75
+ value
76
+ end
77
+
70
78
  def var_against_literal_value?
71
79
  left.identifier? && right.literal? && !right.has_placeholder?
72
80
  end
@@ -76,5 +84,9 @@ class Predicate
76
84
  { identifier.name => right.value }
77
85
  end
78
86
 
87
+ def to_hashes
88
+ [ to_hash, {} ]
89
+ end
90
+
79
91
  end
80
92
  end
@@ -10,5 +10,11 @@ class Predicate
10
10
  left.evaluate(tuple) < right.evaluate(tuple)
11
11
  end
12
12
 
13
+ def assert!(tuple, asserter = Asserter.new)
14
+ l, r = left.evaluate(tuple), right.evaluate(tuple)
15
+ asserter.assert_operator(l, :<, r)
16
+ l
17
+ end
18
+
13
19
  end
14
20
  end
@@ -10,5 +10,11 @@ class Predicate
10
10
  left.evaluate(tuple) <= right.evaluate(tuple)
11
11
  end
12
12
 
13
+ def assert!(tuple, asserter = Asserter.new)
14
+ l, r = left.evaluate(tuple), right.evaluate(tuple)
15
+ asserter.assert_operator(l, :<=, r)
16
+ l
17
+ end
18
+
13
19
  end
14
20
  end
@@ -16,5 +16,16 @@ class Predicate
16
16
  l
17
17
  end
18
18
 
19
+ def to_hashes
20
+ hash = if left.identifier? && right.literal? && !right.has_placeholder?
21
+ { left.name => right.value }
22
+ elsif right.identifier? && left.literal? && !left.has_placeholder?
23
+ { right.name => left.value }
24
+ else
25
+ super
26
+ end
27
+ [ {}, hash ]
28
+ end
29
+
19
30
  end
20
31
  end
@@ -37,5 +37,9 @@ class Predicate
37
37
  {}
38
38
  end
39
39
 
40
+ def to_hashes
41
+ [{}, {}]
42
+ end
43
+
40
44
  end
41
45
  end
@@ -1,7 +1,7 @@
1
1
  class Predicate
2
2
  module Version
3
3
  MAJOR = 2
4
- MINOR = 8
4
+ MINOR = 9
5
5
  TINY = 0
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
data/lib/predicate.rb CHANGED
@@ -165,10 +165,24 @@ class Predicate
165
165
  end
166
166
 
167
167
  # If possible, converts this predicate back to a `{ attr: value, ... }`
168
- # hash. Raises an IllegalArgumentError if the predicate cannot be
169
- # represented that way.
168
+ # hash.
169
+ #
170
+ # Raises an ArgumentError if the predicate cannot be represented that way.
170
171
  def to_hash
171
172
  expr.to_hash
172
173
  end
173
174
 
175
+ # If possible, converts this predicate back to two `{ attr: value, ... }`
176
+ # hashes, where the first one is positive (e.g. x IN ...) and the second one
177
+ # is negative (e.g. x NOT IN ...)
178
+ #
179
+ # The result is such that the original predicate is equivalent to a AND
180
+ # of the two hashes, where the first includes all its values and the second
181
+ # excludes all its values.
182
+ #
183
+ # Raises an ArgumentError if the predicate cannot be represented that way.
184
+ def to_hashes
185
+ expr.to_hashes
186
+ end
187
+
174
188
  end # class Predicate
@@ -7,8 +7,12 @@ shared_examples_for "a comparison factory method" do
7
7
  subject{ self.send(method, true, true) }
8
8
 
9
9
  it_should_behave_like "a predicate AST node"
10
- it{ should be_a(node_class) }
11
- it{ should eql([method, tautology, tautology]) }
10
+ it {
11
+ expect(subject).to be_a(node_class)
12
+ }
13
+ it {
14
+ expect(subject).to eql([method, tautology, tautology])
15
+ }
12
16
  end
13
17
 
14
18
  context 'with a Hash operand (singleton)' do
@@ -18,7 +22,9 @@ shared_examples_for "a comparison factory method" do
18
22
  }
19
23
 
20
24
  it_should_behave_like "a predicate AST node"
21
- it{ should eql(expected) }
25
+ it {
26
+ expect(subject).to eql(expected)
27
+ }
22
28
  end
23
29
 
24
30
  context 'with a Hash operand' do
@@ -30,7 +36,9 @@ shared_examples_for "a comparison factory method" do
30
36
  }
31
37
 
32
38
  it_should_behave_like "a predicate AST node"
33
- it{ should eql(expected) }
39
+ it {
40
+ expect(subject).to eql(expected)
41
+ }
34
42
  end
35
43
 
36
44
  end
@@ -1,20 +1,26 @@
1
1
  require 'spec_helper'
2
2
  shared_examples_for "a predicate AST node" do
3
3
 
4
- it{ should be_a(Sexpr) }
4
+ it {
5
+ expect(subject).to be_a(Sexpr)
6
+ }
5
7
 
6
- it{ should be_a(Predicate::Expr) }
8
+ it {
9
+ expect(subject).to be_a(Predicate::Expr)
10
+ }
7
11
 
8
12
  specify{
9
- (subject.tautology? == subject.is_a?(Predicate::Tautology)).should be(true)
13
+ got = (subject.tautology? == subject.is_a?(Predicate::Tautology))
14
+ expect(got).to be(true)
10
15
  }
11
16
 
12
17
  specify{
13
- (subject.contradiction? == subject.is_a?(Predicate::Contradiction)).should be(true)
18
+ got = (subject.contradiction? == subject.is_a?(Predicate::Contradiction))
19
+ expect(got).to be(true)
14
20
  }
15
21
 
16
22
  specify{
17
- subject.free_variables.should be_a(Array) unless subject.is_a?(Predicate::Native)
23
+ expect(subject.free_variables).to be_a(Array) unless subject.is_a?(Predicate::Native)
18
24
  }
19
25
 
20
26
  end
@@ -7,6 +7,8 @@ class Predicate
7
7
 
8
8
  it_should_behave_like "a predicate AST node"
9
9
 
10
- it{ should be_a(${OpName}) }
10
+ it {
11
+ expect(subject).to be_a(${OpName})
12
+ }
11
13
  end
12
14
  end
@@ -6,8 +6,12 @@ class Predicate
6
6
  subject{ self.and(true, true) }
7
7
 
8
8
  it_should_behave_like "a predicate AST node"
9
- it{ should be_a(And) }
10
- it{ should eql([:and, tautology, tautology]) }
9
+ it {
10
+ expect(subject).to be_a(And)
11
+ }
12
+ it {
13
+ expect(subject).to eql([:and, tautology, tautology])
14
+ }
11
15
 
12
16
  end
13
17
  end
@@ -7,15 +7,21 @@ class Predicate
7
7
  context "when the hash is empty" do
8
8
  let(:h){ {} }
9
9
 
10
- it{ should eq(Factory.tautology) }
10
+ it {
11
+ expect(subject).to eq(Factory.tautology)
12
+ }
11
13
  end
12
14
 
13
15
  context "when the hash is a singelton" do
14
16
  let(:h){ {:x => 12} }
15
17
 
16
18
  it_should_behave_like "a predicate AST node"
17
- it{ should be_a(Eq) }
18
- it{ should eq([:eq, [:identifier, :x], [:literal, 12]]) }
19
+ it {
20
+ expect(subject).to be_a(Eq)
21
+ }
22
+ it {
23
+ expect(subject).to eq([:eq, [:identifier, :x], [:literal, 12]])
24
+ }
19
25
  end
20
26
 
21
27
  context "when the hash is not singleton" do
@@ -27,8 +33,12 @@ class Predicate
27
33
  }
28
34
 
29
35
  it_should_behave_like "a predicate AST node"
30
- it{ should be_a(And) }
31
- it{ should eq(expected) }
36
+ it {
37
+ expect(subject).to be_a(And)
38
+ }
39
+ it {
40
+ expect(subject).to eq(expected)
41
+ }
32
42
  end
33
43
 
34
44
  context "when the value is a Regexp" do
@@ -36,8 +46,12 @@ class Predicate
36
46
  let(:h){ {:x => /[a-z]+/} }
37
47
 
38
48
  it_should_behave_like "a predicate AST node"
39
- it{ should be_a(Match) }
40
- it{ should eq([:match, [:identifier, :x], [:literal, rx]]) }
49
+ it {
50
+ expect(subject).to be_a(Match)
51
+ }
52
+ it {
53
+ expect(subject).to eq([:match, [:identifier, :x], [:literal, rx]])
54
+ }
41
55
  end
42
56
 
43
57
  context "when the hash mixes value types" do
@@ -50,8 +64,12 @@ class Predicate
50
64
  }
51
65
 
52
66
  it_should_behave_like "a predicate AST node"
53
- it{ should be_a(And) }
54
- it{ should eq(expected) }
67
+ it {
68
+ expect(subject).to be_a(And)
69
+ }
70
+ it {
71
+ expect(subject).to eq(expected)
72
+ }
55
73
  end
56
74
 
57
75
  end
@@ -6,6 +6,8 @@ class Predicate
6
6
  subject{ contradiction }
7
7
 
8
8
  it_should_behave_like "a predicate AST node"
9
- it{ should be_a(Contradiction) }
9
+ it {
10
+ expect(subject).to be_a(Contradiction)
11
+ }
10
12
  end
11
13
  end
@@ -6,6 +6,8 @@ class Predicate
6
6
 
7
7
  it_should_behave_like "a predicate AST node"
8
8
 
9
- it{ should be_a(Empty) }
9
+ it {
10
+ expect(subject).to be_a(Empty)
11
+ }
10
12
  end
11
13
  end
@@ -7,43 +7,57 @@ class Predicate
7
7
  context "on Expr" do
8
8
  let(:arg){ Grammar.sexpr([:literal, 12]) }
9
9
 
10
- it{ should be(arg) }
10
+ it {
11
+ expect(subject).to be(arg)
12
+ }
11
13
  end
12
14
 
13
15
  context "on true" do
14
16
  let(:arg){ true }
15
17
 
16
- it{ should be_a(Tautology) }
18
+ it {
19
+ expect(subject).to be_a(Tautology)
20
+ }
17
21
  end
18
22
 
19
23
  context "on false" do
20
24
  let(:arg){ false }
21
25
 
22
- it{ should be_a(Contradiction) }
26
+ it {
27
+ expect(subject).to be_a(Contradiction)
28
+ }
23
29
  end
24
30
 
25
31
  context "on Symbol" do
26
32
  let(:arg){ :name }
27
33
 
28
- it{ should be_a(Identifier) }
34
+ it {
35
+ expect(subject).to be_a(Identifier)
36
+ }
29
37
  end
30
38
 
31
39
  context "on Proc" do
32
40
  let(:arg){ lambda{} }
33
41
 
34
- it{ should be_a(Native) }
42
+ it {
43
+ expect(subject).to be_a(Native)
44
+ }
35
45
  end
36
46
 
37
47
  context "on Array" do
38
48
  let(:arg){ [:identifier, :name] }
39
49
 
40
- it{ should be_a(Identifier) }
50
+ it {
51
+ expect(subject).to be_a(Identifier)
52
+ }
41
53
  end
42
54
 
43
55
  context "on 12" do
44
56
  let(:arg){ 12 }
45
57
 
46
- it{ should be_a(Literal) }
58
+ it {
59
+ expect(subject).to be_a(Literal)
60
+ }
47
61
  end
48
62
 
49
63
  end
@@ -7,15 +7,21 @@ class Predicate
7
7
  context "when the hash is empty" do
8
8
  let(:h){ {} }
9
9
 
10
- it{ should eq(Factory.tautology) }
10
+ it {
11
+ expect(subject).to eq(Factory.tautology)
12
+ }
11
13
  end
12
14
 
13
15
  context "when the hash is a singelton" do
14
16
  let(:h){ {:x => 12} }
15
17
 
16
18
  it_should_behave_like "a predicate AST node"
17
- it{ should be_a(Eq) }
18
- it{ should eq([:eq, [:identifier, :x], [:literal, 12]]) }
19
+ it {
20
+ expect(subject).to be_a(Eq)
21
+ }
22
+ it {
23
+ expect(subject).to eq([:eq, [:identifier, :x], [:literal, 12]])
24
+ }
19
25
  end
20
26
 
21
27
  context "when the hash is not a singleton" do
@@ -27,8 +33,12 @@ class Predicate
27
33
  }
28
34
 
29
35
  it_should_behave_like "a predicate AST node"
30
- it{ should be_a(And) }
31
- it{ should eq(expected) }
36
+ it {
37
+ expect(subject).to be_a(And)
38
+ }
39
+ it {
40
+ expect(subject).to eq(expected)
41
+ }
32
42
  end
33
43
 
34
44
  context "when the hash has array values" do
@@ -40,8 +50,12 @@ class Predicate
40
50
  }
41
51
 
42
52
  it_should_behave_like "a predicate AST node"
43
- it{ should be_a(And) }
44
- it{ should eq(expected) }
53
+ it {
54
+ expect(subject).to be_a(And)
55
+ }
56
+ it {
57
+ expect(subject).to eq(expected)
58
+ }
45
59
  end
46
60
 
47
61
  end
@@ -6,6 +6,8 @@ class Predicate
6
6
 
7
7
  it_should_behave_like "a predicate AST node"
8
8
 
9
- it{ should be_a(HasSize) }
9
+ it {
10
+ expect(subject).to be_a(HasSize)
11
+ }
10
12
  end
11
13
  end
@@ -6,8 +6,12 @@ class Predicate
6
6
  subject{ identifier(:name) }
7
7
 
8
8
  it_should_behave_like "a predicate AST node"
9
- it{ should be_a(Identifier) }
10
- it{ should eql([:identifier, :name]) }
9
+ it {
10
+ expect(subject).to be_a(Identifier)
11
+ }
12
+ it {
13
+ expect(subject).to eql([:identifier, :name])
14
+ }
11
15
 
12
16
  end
13
17
  end
@@ -6,8 +6,12 @@ class Predicate
6
6
  subject{ literal(12) }
7
7
 
8
8
  it_should_behave_like "a predicate AST node"
9
- it{ should be_a(Literal) }
10
- it{ should eql([:literal, 12]) }
9
+ it {
10
+ expect(subject).to be_a(Literal)
11
+ }
12
+ it {
13
+ expect(subject).to eql([:literal, 12])
14
+ }
11
15
 
12
16
  end
13
17
  end
@@ -9,9 +9,13 @@ class Predicate
9
9
 
10
10
  it_should_behave_like "a predicate AST node"
11
11
 
12
- it{ should be_a(Match) }
12
+ it {
13
+ expect(subject).to be_a(Match)
14
+ }
13
15
 
14
- it{ should eql([:match, [:identifier, :name], [:literal, "London"]]) }
16
+ it {
17
+ expect(subject).to eql([:match, [:identifier, :name], [:literal, "London"]])
18
+ }
15
19
  end
16
20
 
17
21
  context 'with options' do
@@ -19,9 +23,13 @@ class Predicate
19
23
 
20
24
  it_should_behave_like "a predicate AST node"
21
25
 
22
- it{ should be_a(Match) }
26
+ it {
27
+ expect(subject).to be_a(Match)
28
+ }
23
29
 
24
- it{ should eql([:match, [:identifier, :name], [:literal, "London"], {case_sensitive: false}]) }
30
+ it {
31
+ expect(subject).to eql([:match, [:identifier, :name], [:literal, "London"], {case_sensitive: false}])
32
+ }
25
33
  end
26
34
 
27
35
  end
@@ -10,9 +10,13 @@ class Predicate
10
10
 
11
11
  it_should_behave_like "a predicate AST node"
12
12
 
13
- it{ should be_a(Native) }
13
+ it {
14
+ expect(subject).to be_a(Native)
15
+ }
14
16
 
15
- it{ should eql([:native, proc]) }
17
+ it {
18
+ expect(subject).to eql([:native, proc])
19
+ }
16
20
  end
17
21
 
18
22
  end