diff --git a/spec/factory/shared/a_comparison_factory_method.rb b/spec/factory/shared/a_comparison_factory_method.rb index 4fd95bd..9364e18 100644 --- a/spec/factory/shared/a_comparison_factory_method.rb +++ b/spec/factory/shared/a_comparison_factory_method.rb @@ -7,8 +7,12 @@ subject{ self.send(method, true, true) } it_should_behave_like "a predicate AST node" - it{ should be_a(node_class) } - it{ should eql([method, tautology, tautology]) } + it { + expect(subject).to be_a(node_class) + } + it { + expect(subject).to eql([method, tautology, tautology]) + } end context 'with a Hash operand (singleton)' do @@ -18,7 +22,9 @@ } it_should_behave_like "a predicate AST node" - it{ should eql(expected) } + it { + expect(subject).to eql(expected) + } end context 'with a Hash operand' do @@ -30,7 +36,9 @@ } it_should_behave_like "a predicate AST node" - it{ should eql(expected) } + it { + expect(subject).to eql(expected) + } end end diff --git a/spec/factory/shared/a_predicate_ast_node.rb b/spec/factory/shared/a_predicate_ast_node.rb index c1f54ca..9e6bfec 100644 --- a/spec/factory/shared/a_predicate_ast_node.rb +++ b/spec/factory/shared/a_predicate_ast_node.rb @@ -1,20 +1,26 @@ require 'spec_helper' shared_examples_for "a predicate AST node" do - it{ should be_a(Sexpr) } + it { + expect(subject).to be_a(Sexpr) + } - it{ should be_a(Predicate::Expr) } + it { + expect(subject).to be_a(Predicate::Expr) + } specify{ - (subject.tautology? == subject.is_a?(Predicate::Tautology)).should be(true) + got = (subject.tautology? == subject.is_a?(Predicate::Tautology)) + expect(got).to be(true) } specify{ - (subject.contradiction? == subject.is_a?(Predicate::Contradiction)).should be(true) + got = (subject.contradiction? == subject.is_a?(Predicate::Contradiction)) + expect(got).to be(true) } specify{ - subject.free_variables.should be_a(Array) unless subject.is_a?(Predicate::Native) + expect(subject.free_variables).to be_a(Array) unless subject.is_a?(Predicate::Native) } end diff --git a/spec/factory/test_${op_name}.rb.jeny b/spec/factory/test_${op_name}.rb.jeny index fc73c6e..cb7f3fe 100644 --- a/spec/factory/test_${op_name}.rb.jeny +++ b/spec/factory/test_${op_name}.rb.jeny @@ -7,6 +7,8 @@ class Predicate it_should_behave_like "a predicate AST node" - it{ should be_a(${OpName}) } + it { + expect(subject).to be_a(${OpName}) + } end end diff --git a/spec/factory/test_and.rb b/spec/factory/test_and.rb index b75fa22..25b539f 100644 --- a/spec/factory/test_and.rb +++ b/spec/factory/test_and.rb @@ -6,8 +6,12 @@ class Predicate subject{ self.and(true, true) } it_should_behave_like "a predicate AST node" - it{ should be_a(And) } - it{ should eql([:and, tautology, tautology]) } + it { + expect(subject).to be_a(And) + } + it { + expect(subject).to eql([:and, tautology, tautology]) + } end end diff --git a/spec/factory/test_comp.rb b/spec/factory/test_comp.rb index a288235..d70697d 100644 --- a/spec/factory/test_comp.rb +++ b/spec/factory/test_comp.rb @@ -7,15 +7,21 @@ class Predicate context "when the hash is empty" do let(:h){ {} } - it{ should eq(Factory.tautology) } + it { + expect(subject).to eq(Factory.tautology) + } end context "when the hash is a singelton" do let(:h){ {:x => 12} } it_should_behave_like "a predicate AST node" - it{ should be_a(Eq) } - it{ should eq([:eq, [:identifier, :x], [:literal, 12]]) } + it { + expect(subject).to be_a(Eq) + } + it { + expect(subject).to eq([:eq, [:identifier, :x], [:literal, 12]]) + } end context "when the hash is not singleton" do @@ -27,8 +33,12 @@ class Predicate } it_should_behave_like "a predicate AST node" - it{ should be_a(And) } - it{ should eq(expected) } + it { + expect(subject).to be_a(And) + } + it { + expect(subject).to eq(expected) + } end context "when the value is a Regexp" do @@ -36,8 +46,12 @@ class Predicate let(:h){ {:x => /[a-z]+/} } it_should_behave_like "a predicate AST node" - it{ should be_a(Match) } - it{ should eq([:match, [:identifier, :x], [:literal, rx]]) } + it { + expect(subject).to be_a(Match) + } + it { + expect(subject).to eq([:match, [:identifier, :x], [:literal, rx]]) + } end context "when the hash mixes value types" do @@ -50,8 +64,12 @@ class Predicate } it_should_behave_like "a predicate AST node" - it{ should be_a(And) } - it{ should eq(expected) } + it { + expect(subject).to be_a(And) + } + it { + expect(subject).to eq(expected) + } end end diff --git a/spec/factory/test_contradiction.rb b/spec/factory/test_contradiction.rb index 97bdd79..1b0ef2d 100644 --- a/spec/factory/test_contradiction.rb +++ b/spec/factory/test_contradiction.rb @@ -6,6 +6,8 @@ class Predicate subject{ contradiction } it_should_behave_like "a predicate AST node" - it{ should be_a(Contradiction) } + it { + expect(subject).to be_a(Contradiction) + } end end diff --git a/spec/factory/test_empty.rb b/spec/factory/test_empty.rb index fb0bfd6..98e647b 100644 --- a/spec/factory/test_empty.rb +++ b/spec/factory/test_empty.rb @@ -6,6 +6,8 @@ class Predicate it_should_behave_like "a predicate AST node" - it{ should be_a(Empty) } + it { + expect(subject).to be_a(Empty) + } end end diff --git a/spec/factory/test_factor_predicate.rb b/spec/factory/test_factor_predicate.rb index 166ef85..6800e33 100644 --- a/spec/factory/test_factor_predicate.rb +++ b/spec/factory/test_factor_predicate.rb @@ -7,43 +7,57 @@ class Predicate context "on Expr" do let(:arg){ Grammar.sexpr([:literal, 12]) } - it{ should be(arg) } + it { + expect(subject).to be(arg) + } end context "on true" do let(:arg){ true } - it{ should be_a(Tautology) } + it { + expect(subject).to be_a(Tautology) + } end context "on false" do let(:arg){ false } - it{ should be_a(Contradiction) } + it { + expect(subject).to be_a(Contradiction) + } end context "on Symbol" do let(:arg){ :name } - it{ should be_a(Identifier) } + it { + expect(subject).to be_a(Identifier) + } end context "on Proc" do let(:arg){ lambda{} } - it{ should be_a(Native) } + it { + expect(subject).to be_a(Native) + } end context "on Array" do let(:arg){ [:identifier, :name] } - it{ should be_a(Identifier) } + it { + expect(subject).to be_a(Identifier) + } end context "on 12" do let(:arg){ 12 } - it{ should be_a(Literal) } + it { + expect(subject).to be_a(Literal) + } end end diff --git a/spec/factory/test_from_hash.rb b/spec/factory/test_from_hash.rb index 3384bb9..a2ae3be 100644 --- a/spec/factory/test_from_hash.rb +++ b/spec/factory/test_from_hash.rb @@ -7,15 +7,21 @@ class Predicate context "when the hash is empty" do let(:h){ {} } - it{ should eq(Factory.tautology) } + it { + expect(subject).to eq(Factory.tautology) + } end context "when the hash is a singelton" do let(:h){ {:x => 12} } it_should_behave_like "a predicate AST node" - it{ should be_a(Eq) } - it{ should eq([:eq, [:identifier, :x], [:literal, 12]]) } + it { + expect(subject).to be_a(Eq) + } + it { + expect(subject).to eq([:eq, [:identifier, :x], [:literal, 12]]) + } end context "when the hash is not a singleton" do @@ -27,8 +33,12 @@ class Predicate } it_should_behave_like "a predicate AST node" - it{ should be_a(And) } - it{ should eq(expected) } + it { + expect(subject).to be_a(And) + } + it { + expect(subject).to eq(expected) + } end context "when the hash has array values" do @@ -40,8 +50,12 @@ class Predicate } it_should_behave_like "a predicate AST node" - it{ should be_a(And) } - it{ should eq(expected) } + it { + expect(subject).to be_a(And) + } + it { + expect(subject).to eq(expected) + } end end diff --git a/spec/factory/test_has_size.rb b/spec/factory/test_has_size.rb index af09bc7..6438fbb 100644 --- a/spec/factory/test_has_size.rb +++ b/spec/factory/test_has_size.rb @@ -6,6 +6,8 @@ class Predicate it_should_behave_like "a predicate AST node" - it{ should be_a(HasSize) } + it { + expect(subject).to be_a(HasSize) + } end end diff --git a/spec/factory/test_identifier.rb b/spec/factory/test_identifier.rb index d197c32..b38ea2a 100644 --- a/spec/factory/test_identifier.rb +++ b/spec/factory/test_identifier.rb @@ -6,8 +6,12 @@ class Predicate subject{ identifier(:name) } it_should_behave_like "a predicate AST node" - it{ should be_a(Identifier) } - it{ should eql([:identifier, :name]) } + it { + expect(subject).to be_a(Identifier) + } + it { + expect(subject).to eql([:identifier, :name]) + } end end diff --git a/spec/factory/test_literal.rb b/spec/factory/test_literal.rb index c4babbf..62ec592 100644 --- a/spec/factory/test_literal.rb +++ b/spec/factory/test_literal.rb @@ -6,8 +6,12 @@ class Predicate subject{ literal(12) } it_should_behave_like "a predicate AST node" - it{ should be_a(Literal) } - it{ should eql([:literal, 12]) } + it { + expect(subject).to be_a(Literal) + } + it { + expect(subject).to eql([:literal, 12]) + } end end diff --git a/spec/factory/test_match.rb b/spec/factory/test_match.rb index 43434de..fb5dff3 100644 --- a/spec/factory/test_match.rb +++ b/spec/factory/test_match.rb @@ -9,9 +9,13 @@ class Predicate it_should_behave_like "a predicate AST node" - it{ should be_a(Match) } + it { + expect(subject).to be_a(Match) + } - it{ should eql([:match, [:identifier, :name], [:literal, "London"]]) } + it { + expect(subject).to eql([:match, [:identifier, :name], [:literal, "London"]]) + } end context 'with options' do @@ -19,9 +23,13 @@ class Predicate it_should_behave_like "a predicate AST node" - it{ should be_a(Match) } + it { + expect(subject).to be_a(Match) + } - it{ should eql([:match, [:identifier, :name], [:literal, "London"], {case_sensitive: false}]) } + it { + expect(subject).to eql([:match, [:identifier, :name], [:literal, "London"], {case_sensitive: false}]) + } end end diff --git a/spec/factory/test_native.rb b/spec/factory/test_native.rb index 23b95b1..ea85560 100644 --- a/spec/factory/test_native.rb +++ b/spec/factory/test_native.rb @@ -10,9 +10,13 @@ class Predicate it_should_behave_like "a predicate AST node" - it{ should be_a(Native) } + it { + expect(subject).to be_a(Native) + } - it{ should eql([:native, proc]) } + it { + expect(subject).to eql([:native, proc]) + } end end diff --git a/spec/factory/test_not.rb b/spec/factory/test_not.rb index 3b5eb68..940afa8 100644 --- a/spec/factory/test_not.rb +++ b/spec/factory/test_not.rb @@ -6,8 +6,12 @@ class Predicate subject{ self.not(true) } it_should_behave_like "a predicate AST node" - it{ should be_a(Not) } - it{ should eql([:not, tautology]) } + it { + expect(subject).to be_a(Not) + } + it { + expect(subject).to eql([:not, tautology]) + } end end diff --git a/spec/factory/test_or.rb b/spec/factory/test_or.rb index e4b84b4..e4251cf 100644 --- a/spec/factory/test_or.rb +++ b/spec/factory/test_or.rb @@ -6,8 +6,12 @@ class Predicate subject{ self.or(true, true) } it_should_behave_like "a predicate AST node" - it{ should be_a(Or) } - it{ should eql([:or, tautology, tautology]) } + it { + expect(subject).to be_a(Or) + } + it { + expect(subject).to eql([:or, tautology, tautology]) + } end end diff --git a/spec/factory/test_qualified_identifier.rb b/spec/factory/test_qualified_identifier.rb index eeb5822..36bed7f 100644 --- a/spec/factory/test_qualified_identifier.rb +++ b/spec/factory/test_qualified_identifier.rb @@ -7,9 +7,13 @@ class Predicate it_should_behave_like "a predicate AST node" - it{ should be_a(QualifiedIdentifier) } + it{ + expect(subject).to be_a(QualifiedIdentifier) + } - it{ should eql([:qualified_identifier, :t, :name]) } + it{ + expect(subject).to eql([:qualified_identifier, :t, :name]) + } end end diff --git a/spec/factory/test_set_ops.rb b/spec/factory/test_set_ops.rb index 1f401ba..e678e2a 100644 --- a/spec/factory/test_set_ops.rb +++ b/spec/factory/test_set_ops.rb @@ -9,9 +9,13 @@ class Predicate subject{ Factory.send(op_name, :x, [2, 3]) } - it{ should be_a(op_class) } + it { + expect(subject).to be_a(op_class) + } - it{ should eq([op_name, [:identifier, :x], [:literal, [2, 3]]]) } + it { + expect(subject).to eq([op_name, [:identifier, :x], [:literal, [2, 3]]]) + } end end diff --git a/spec/factory/test_tautology.rb b/spec/factory/test_tautology.rb index b34c847..1e93e8e 100644 --- a/spec/factory/test_tautology.rb +++ b/spec/factory/test_tautology.rb @@ -6,7 +6,9 @@ class Predicate subject{ tautology } it_should_behave_like "a predicate AST node" - it{ should be_a(Tautology) } + it { + expect(subject).to be_a(Tautology) + } end end diff --git a/spec/factory/test_var.rb b/spec/factory/test_var.rb index 22dacfe..9a47cca 100644 --- a/spec/factory/test_var.rb +++ b/spec/factory/test_var.rb @@ -7,16 +7,24 @@ class Predicate subject{ var("a.b.c", :dig) } it_should_behave_like "a predicate AST node" - it{ should be_a(Var) } - it{ should eql([:var, "a.b.c", :dig]) } + it { + expect(subject).to be_a(Var) + } + it { + expect(subject).to eql([:var, "a.b.c", :dig]) + } end context 'when used with an array' do subject{ var([:a, :b, :c], :dig) } it_should_behave_like "a predicate AST node" - it{ should be_a(Var) } - it{ should eql([:var, [:a, :b, :c], :dig]) } + it { + expect(subject).to be_a(Var) + } + it { + expect(subject).to eql([:var, [:a, :b, :c], :dig]) + } end end end diff --git a/spec/grammar/test_match.rb b/spec/grammar/test_match.rb index e10c0a5..23a75d0 100644 --- a/spec/grammar/test_match.rb +++ b/spec/grammar/test_match.rb @@ -6,10 +6,10 @@ class Predicate subject{ Grammar[:tautology] } it 'matches a tautology' do - subject.should be_match([:tautology, true]) + expect(subject).to be_match([:tautology, true]) end it 'does no match a wrong one' do - subject.should_not be_match([:tautology, false]) + expect(subject).not_to be_match([:tautology, false]) end end @@ -17,10 +17,10 @@ class Predicate subject{ Grammar[:contradiction] } it 'matches a tautology' do - subject.should be_match([:contradiction, false]) + expect(subject).to be_match([:contradiction, false]) end it 'does no match a wrong one' do - subject.should_not be_match([:contradiction, true]) + expect(subject).not_to be_match([:contradiction, true]) end end @@ -28,11 +28,11 @@ class Predicate subject{ Grammar[:identifier] } it 'matches a valid ast' do - subject.should be_match([:identifier, :id]) + expect(subject).to be_match([:identifier, :id]) end it 'does not match an invalid ast' do - subject.should_not be_match([:identifier, 12]) + expect(subject).not_to be_match([:identifier, 12]) end end @@ -40,8 +40,8 @@ class Predicate subject{ Grammar[:literal] } it 'matches valid ASTs' do - subject.should be_match([:literal, 12]) - subject.should be_match([:literal, true]) + expect(subject).to be_match([:literal, 12]) + expect(subject).to be_match([:literal, true]) end end @@ -49,10 +49,10 @@ class Predicate subject{ Grammar[:in] } it 'matches valid ASTs' do - subject.should be_match([:in, [:identifier, :x], [2, 3]]) + expect(subject).to be_match([:in, [:identifier, :x], [2, 3]]) end it 'does not match invalid ASTs' do - subject.should_not be_match([:in, :x]) + expect(subject).not_to be_match([:in, :x]) end end @@ -60,10 +60,10 @@ class Predicate subject{ Grammar[:eq] } it 'matches valid ASTs' do - subject.should be_match([:eq, [:identifier, :age], [:literal, 12]]) + expect(subject).to be_match([:eq, [:identifier, :age], [:literal, 12]]) end it 'does not match invalid ASTs' do - subject.should_not be_match([:neq, [:identifier, :age], [:literal, 12]]) + expect(subject).not_to be_match([:neq, [:identifier, :age], [:literal, 12]]) end end @@ -71,10 +71,10 @@ class Predicate subject{ Grammar[:neq] } it 'matches valid ASTs' do - subject.should be_match([:neq, [:identifier, :age], [:literal, 12]]) + expect(subject).to be_match([:neq, [:identifier, :age], [:literal, 12]]) end it 'does not match invalid ASTs' do - subject.should_not be_match([:eq, [:identifier, :age], [:literal, 12]]) + expect(subject).not_to be_match([:eq, [:identifier, :age], [:literal, 12]]) end end @@ -82,11 +82,11 @@ class Predicate subject{ Grammar[:match] } it 'matches valid ASTs' do - subject.should be_match([:match, [:identifier, :name], [:literal, "London"], {}]) - subject.should be_match([:match, [:identifier, :name], [:literal, /London/], {}]) + expect(subject).to be_match([:match, [:identifier, :name], [:literal, "London"], {}]) + expect(subject).to be_match([:match, [:identifier, :name], [:literal, /London/], {}]) end it 'does not match invalid ASTs' do - subject.should_not be_match([:native, 12]) + expect(subject).not_to be_match([:native, 12]) end end @@ -94,10 +94,10 @@ class Predicate subject{ Grammar[:native] } it 'matches valid ASTs' do - subject.should be_match([:native, lambda{}]) + expect(subject).to be_match([:native, lambda{}]) end it 'does not match invalid ASTs' do - subject.should_not be_match([:native, 12]) + expect(subject).not_to be_match([:native, 12]) end end diff --git a/spec/grammar/test_sexpr.rb b/spec/grammar/test_sexpr.rb index 58776dd..fbcd3ed 100644 --- a/spec/grammar/test_sexpr.rb +++ b/spec/grammar/test_sexpr.rb @@ -17,103 +17,135 @@ class Predicate } before do - subject.should be_a(Sexpr) + expect(subject).to be_a(Sexpr) end describe "tautology" do let(:expr){ [:tautology, true] } - it{ should be_a(Tautology) } + it { + expect(subject).to be_a(Tautology) + } end describe "contradiction" do let(:expr){ [:contradiction, false] } - it{ should be_a(Contradiction) } + it { + expect(subject).to be_a(Contradiction) + } end describe "identifier" do let(:expr){ [:identifier, :name] } - it{ should be_a(Identifier) } + it { + expect(subject).to be_a(Identifier) + } end describe "and" do let(:expr){ [:and, contradiction, contradiction] } - it{ should be_a(And) } + it { + expect(subject).to be_a(And) + } end describe "or" do let(:expr){ [:or, contradiction, contradiction] } - it{ should be_a(Or) } + it { + expect(subject).to be_a(Or) + } end describe "not" do let(:expr){ [:not, contradiction] } - it{ should be_a(Not) } + it { + expect(subject).to be_a(Not) + } end describe "eq" do let(:expr){ [:eq, identifier, identifier] } - it{ should be_a(Eq) } + it { + expect(subject).to be_a(Eq) + } end describe "neq" do let(:expr){ [:neq, identifier, identifier] } - it{ should be_a(Neq) } + it { + expect(subject).to be_a(Neq) + } end describe "gt" do let(:expr){ [:gt, identifier, identifier] } - it{ should be_a(Gt) } + it { + expect(subject).to be_a(Gt) + } end describe "gte" do let(:expr){ [:gte, identifier, identifier] } - it{ should be_a(Gte) } + it { + expect(subject).to be_a(Gte) + } end describe "lt" do let(:expr){ [:lt, identifier, identifier] } - it{ should be_a(Lt) } + it { + expect(subject).to be_a(Lt) + } end describe "lte" do let(:expr){ [:lte, identifier, identifier] } - it{ should be_a(Lte) } + it { + expect(subject).to be_a(Lte) + } end describe "in" do let(:expr){ [:in, identifier, values] } - it{ should be_a(In) } + it { + expect(subject).to be_a(In) + } end describe "intersect" do let(:expr){ [:intersect, identifier, values] } - it{ should be_a(Intersect) } + it { + expect(subject).to be_a(Intersect) + } end describe "literal" do let(:expr){ [:literal, 12] } - it{ should be_a(Literal) } + it { + expect(subject).to be_a(Literal) + } end describe "native" do let(:expr){ [:native, lambda{}] } - it{ should be_a(Native) } + it { + expect(subject).to be_a(Native) + } end end diff --git a/spec/nodes/and/test_and_split.rb b/spec/nodes/and/test_and_split.rb index d4f4a6e..536996c 100644 --- a/spec/nodes/and/test_and_split.rb +++ b/spec/nodes/and/test_and_split.rb @@ -12,19 +12,25 @@ class Predicate context 'when fully covered' do let(:list){ [:x, :y] } - it{ should eq([predicate, tautology]) } + it { + expect(subject).to eq([predicate, tautology]) + } end context 'when not covered at all' do let(:list){ [:name] } - it{ should eq([tautology, predicate]) } + it { + expect(subject).to eq([tautology, predicate]) + } end context 'when partially covered' do let(:list){ [:x] } - it{ should eq([Factory.eq(:x, 2), Factory.eq(:y, 3)]) } + it { + expect(subject).to eq([Factory.eq(:x, 2), Factory.eq(:y, 3)]) + } end end @@ -34,31 +40,41 @@ class Predicate context 'when fully covered' do let(:list){ [:x, :y, :z] } - it{ should eq([predicate, tautology]) } + it { + expect(subject).to eq([predicate, tautology]) + } end context 'when not covered at all' do let(:list){ [:name] } - it{ should eq([tautology, predicate]) } + it { + expect(subject).to eq([tautology, predicate]) + } end context 'when partially covered but split-able' do let(:list){ [:x] } - it{ should eq([Factory.eq(:x, 2), Factory.eq(:y, :z)]) } + it { + expect(subject).to eq([Factory.eq(:x, 2), Factory.eq(:y, :z)]) + } end context 'when partially covered but split-able (2)' do let(:list){ [:y] } - it{ should eq([Factory.eq(:y, :z), Factory.eq(:x, 2)]) } + it { + expect(subject).to eq([Factory.eq(:y, :z), Factory.eq(:x, 2)]) + } end context 'when partially covered but not split-able' do let(:list){ [:x, :y] } - it{ should eq([predicate, tautology]) } + it { + expect(subject).to eq([predicate, tautology]) + } end end @@ -70,13 +86,17 @@ class Predicate context 'when fully covered' do let(:list){ [:x, :y, :z] } - it{ should eq([predicate, tautology]) } + it { + expect(subject).to eq([predicate, tautology]) + } end context 'when not covered' do let(:list){ [:y] } - it{ should eq([right, left]) } + it { + expect(subject).to eq([right, left]) + } end end diff --git a/spec/nodes/dyadic_comp/test_and_split.rb b/spec/nodes/dyadic_comp/test_and_split.rb index 2d6af13..e5adfc2 100644 --- a/spec/nodes/dyadic_comp/test_and_split.rb +++ b/spec/nodes/dyadic_comp/test_and_split.rb @@ -10,13 +10,17 @@ class Predicate context 'when included' do let(:list){ [:id, :name] } - it{ should eq([predicate, tautology]) } + it { + expect(subject).to eq([predicate, tautology]) + } end context 'when not include' do let(:list){ [:name] } - it{ should eq([tautology, predicate]) } + it { + expect(subject).to eq([tautology, predicate]) + } end context 'with attributes on both sides' do @@ -24,20 +28,26 @@ class Predicate context 'when full at left' do let(:list){ [:x, :y] } - - it{ should eq([predicate, tautology]) } + + it { + expect(subject).to eq([predicate, tautology]) + } end - + context 'none at left' do let(:list){ [] } - - it{ should eq([tautology, predicate]) } + + it { + expect(subject).to eq([tautology, predicate]) + } end context 'mix' do let(:list){ [:y] } - it{ should eq([predicate, tautology]) } + it { + expect(subject).to eq([predicate, tautology]) + } end end diff --git a/spec/nodes/eq/test_and.rb b/spec/nodes/eq/test_and.rb index 9820b44..3998928 100644 --- a/spec/nodes/eq/test_and.rb +++ b/spec/nodes/eq/test_and.rb @@ -11,25 +11,33 @@ class Predicate context 'with an eq leading to a contradiction' do let(:right){ Factory.eq(:x, 3) } - it{ should be_a(Contradiction) } + it{ + expect(subject).to be_a(Contradiction) + } end context 'with an IN on same variable and literal' do let(:right){ Factory.in(:x, [2,4]) } - it{ should be(left) } + it{ + expect(subject).to be(left) + } end context 'with an IN on same variable and opaque' do let(:right){ Factory.in(:x, Factory.opaque([3,4])) } - it{ should be_a(And) } + it{ + expect(subject).to be_a(And) + } end context 'with an IN having a placeholder' do let(:right){ Factory.in(:x, Factory.placeholder) } - it{ should be_a(And) } + it{ + expect(subject).to be_a(And) + } end end diff --git a/spec/nodes/identifier/test_and_split.rb b/spec/nodes/identifier/test_and_split.rb index 4c39cef..02acc68 100644 --- a/spec/nodes/identifier/test_and_split.rb +++ b/spec/nodes/identifier/test_and_split.rb @@ -10,13 +10,17 @@ class Predicate context 'when included' do let(:list){ [:id, :name] } - it{ should eq([predicate, tautology]) } + it { + expect(subject).to eq([predicate, tautology]) + } end context 'when not include' do let(:list){ [:name] } - it{ should eq([tautology, predicate]) } + it { + expect(subject).to eq([tautology, predicate]) + } end end diff --git a/spec/nodes/identifier/test_free_variables.rb b/spec/nodes/identifier/test_free_variables.rb index c325dc2..ebc37d7 100644 --- a/spec/nodes/identifier/test_free_variables.rb +++ b/spec/nodes/identifier/test_free_variables.rb @@ -6,7 +6,9 @@ class Predicate subject{ expr.free_variables } - it{ should eq([:id]) } + it { + expect(subject).to eq([:id]) + } end end diff --git a/spec/nodes/identifier/test_name.rb b/spec/nodes/identifier/test_name.rb index 323a963..e0b647b 100644 --- a/spec/nodes/identifier/test_name.rb +++ b/spec/nodes/identifier/test_name.rb @@ -6,7 +6,9 @@ class Predicate subject{ expr.name } - it{ should eq(:id) } + it { + expect(subject).to eq(:id) + } end end diff --git a/spec/nodes/in/test_and.rb b/spec/nodes/in/test_and.rb index 917fa58..1bf32e3 100644 --- a/spec/nodes/in/test_and.rb +++ b/spec/nodes/in/test_and.rb @@ -11,37 +11,49 @@ class Predicate context 'with an eq on same variable' do let(:right){ Factory.eq(:x, 2) } - it{ should be(right) } + it { + expect(subject).to be(right) + } end context 'with an eq on same variable yielding a contradiction' do let(:right){ Factory.eq(:x, 3) } - it{ should eql(Factory.contradiction) } + it { + expect(subject).to eql(Factory.contradiction) + } end context 'with an in on same variable' do let(:right){ Factory.in(:x, [2, 4, 5]) } - it{ should eql(Factory.in(:x, [2, 4])) } + it { + expect(subject).to eql(Factory.in(:x, [2, 4])) + } end context 'with an in on same variable, leading to a singleton' do let(:right){ Factory.in(:x, [2]) } - it{ should eql(Factory.eq(:x, 2)) } + it { + expect(subject).to eql(Factory.eq(:x, 2)) + } end context 'with an eq on same variable, leading to a singleton' do let(:right){ Factory.in(:x, [2, 5]) } - it{ should eql(Factory.eq(:x, 2)) } + it { + expect(subject).to eql(Factory.eq(:x, 2)) + } end context 'with an in on same variable, leading to a empty set' do let(:right){ Factory.in(:x, [5]) } - it{ should eql(Factory.contradiction) } + it { + expect(subject).to eql(Factory.contradiction) + } end end diff --git a/spec/nodes/nadic_bool/test_free_variables.rb b/spec/nodes/nadic_bool/test_free_variables.rb index 39ecb1f..c37ee4a 100644 --- a/spec/nodes/nadic_bool/test_free_variables.rb +++ b/spec/nodes/nadic_bool/test_free_variables.rb @@ -7,7 +7,9 @@ class Predicate context "on a complex attribute comparison" do let(:expr){ Factory.comp(:neq, :x => :y, :z => 2) } - it{ should eq([:x, :y, :z]) } + it { + expect(subject).to eq([:x, :y, :z]) + } end end diff --git a/spec/nodes/or/test_and_split.rb b/spec/nodes/or/test_and_split.rb index 5bad8be..9a5c769 100644 --- a/spec/nodes/or/test_and_split.rb +++ b/spec/nodes/or/test_and_split.rb @@ -12,13 +12,17 @@ class Predicate context 'when fully covered' do let(:list){ [:x, :y] } - it{ should eq([predicate, tautology]) } + it { + expect(subject).to eq([predicate, tautology]) + } end context 'when fully disjoint' do let(:list){ [:z] } - it{ should eq([tautology, predicate]) } + it { + expect(subject).to eq([tautology, predicate]) + } end end diff --git a/spec/nodes/qualified_identifier/test_and_split.rb b/spec/nodes/qualified_identifier/test_and_split.rb index 13f2162..ee7fa1f 100644 --- a/spec/nodes/qualified_identifier/test_and_split.rb +++ b/spec/nodes/qualified_identifier/test_and_split.rb @@ -10,13 +10,17 @@ class Predicate context 'when included' do let(:list){ [:"t.id", :name] } - it{ should eq([predicate, tautology]) } + it { + expect(subject).to eq([predicate, tautology]) + } end context 'when not include' do let(:list){ [:name] } - it{ should eq([tautology, predicate]) } + it { + expect(subject).to eq([tautology, predicate]) + } end end diff --git a/spec/nodes/qualified_identifier/test_free_variables.rb b/spec/nodes/qualified_identifier/test_free_variables.rb index 08c6488..61a6357 100644 --- a/spec/nodes/qualified_identifier/test_free_variables.rb +++ b/spec/nodes/qualified_identifier/test_free_variables.rb @@ -6,7 +6,9 @@ class Predicate subject{ expr.free_variables } - it{ should eq([:"t.id"]) } + it { + expect(subject).to eq([:"t.id"]) + } end end diff --git a/spec/nodes/qualified_identifier/test_name.rb b/spec/nodes/qualified_identifier/test_name.rb index 60e1526..fafbd61 100644 --- a/spec/nodes/qualified_identifier/test_name.rb +++ b/spec/nodes/qualified_identifier/test_name.rb @@ -6,7 +6,9 @@ class Predicate subject{ expr.name } - it{ should eq(:id) } + it { + expect(subject).to eq(:id) + } end end diff --git a/spec/nodes/qualified_identifier/test_qualifier.rb b/spec/nodes/qualified_identifier/test_qualifier.rb index 33bdc33..b58cf52 100644 --- a/spec/nodes/qualified_identifier/test_qualifier.rb +++ b/spec/nodes/qualified_identifier/test_qualifier.rb @@ -6,7 +6,9 @@ class Predicate subject{ expr.qualifier } - it{ should eq(:t) } + it { + expect(subject).to eq(:t) + } end end diff --git a/spec/predicate/test_and_split.rb b/spec/predicate/test_and_split.rb index d7260cd..1517960 100644 --- a/spec/predicate/test_and_split.rb +++ b/spec/predicate/test_and_split.rb @@ -8,97 +8,129 @@ class Predicate context "on tautology" do let(:pred){ p.tautology } - it{ should eq([p.tautology, p.tautology]) } + it { + expect(subject).to eq([p.tautology, p.tautology]) + } end context "on contradiction" do let(:pred){ p.contradiction } - it{ should eq([p.tautology, pred]) } + it { + expect(subject).to eq([p.tautology, pred]) + } end context "on identifier (included)" do let(:pred){ p.identifier(:x) } - it{ should eq([ pred, p.tautology ]) } + it { + expect(subject).to eq([ pred, p.tautology ]) + } end context "on identifier (excluded)" do let(:pred){ p.identifier(:y) } - it{ should eq([ p.tautology, pred ]) } + it { + expect(subject).to eq([ p.tautology, pred ]) + } end context "on not (included)" do let(:pred){ p.not(:x) } - it{ should eq([ pred, p.tautology ]) } + it { + expect(subject).to eq([ pred, p.tautology ]) + } end context "on not (excluded)" do let(:pred){ p.not(:y) } - it{ should eq([ p.tautology, pred ]) } + it { + expect(subject).to eq([ p.tautology, pred ]) + } end context "on eq (included)" do let(:pred){ p.eq(:x, 2) } - it{ should eq([ pred, p.tautology ]) } + it { + expect(subject).to eq([ pred, p.tautology ]) + } end context "on eq (excluded)" do let(:pred){ p.eq(:y, 2) } - it{ should eq([ p.tautology, pred ]) } + it { + expect(subject).to eq([ p.tautology, pred ]) + } end context "on eq with placeholder" do let(:pred){ p.eq(:x, p.placeholder) } - it{ should eq([ pred, p.tautology ]) } + it { + expect(subject).to eq([ pred, p.tautology ]) + } end context "on in with placeholder" do let(:pred){ p.in(:x, p.placeholder) } - it{ should eq([ pred, p.tautology ]) } + it { + expect(subject).to eq([ pred, p.tautology ]) + } end context "on match (included)" do let(:pred){ p.match(:x, "London") } - it{ should eq([ pred, p.tautology ]) } + it { + expect(subject).to eq([ pred, p.tautology ]) + } end context "on match (excluded)" do let(:pred){ p.match(:y, "London") } - it{ should eq([ p.tautology, pred ]) } + it { + expect(subject).to eq([ p.tautology, pred ]) + } end context "on match (included on right)" do let(:pred){ p.match(:y, :x) } - it{ should eq([ pred, p.tautology ]) } + it { + expect(subject).to eq([ pred, p.tautology ]) + } end context "on intersect" do let(:pred){ p.intersect(:x, [1, 2]) } - it{ should eq([ pred, p.tautology ]) } + it { + expect(subject).to eq([ pred, p.tautology ]) + } end context "on subset" do let(:pred){ p.subset(:x, [1, 2]) } - it{ should eq([ pred, p.tautology ]) } + it { + expect(subject).to eq([ pred, p.tautology ]) + } end context "on superset" do let(:pred){ p.superset(:x, [1, 2]) } - it{ should eq([ pred, p.tautology ]) } + it { + expect(subject).to eq([ pred, p.tautology ]) + } end end diff --git a/spec/predicate/test_attr_split.rb b/spec/predicate/test_attr_split.rb index 6c03f7f..97aef61 100644 --- a/spec/predicate/test_attr_split.rb +++ b/spec/predicate/test_attr_split.rb @@ -8,73 +8,97 @@ class Predicate context "on tautology" do let(:pred){ p.tautology } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on contradiction" do let(:pred){ p.contradiction } - it{ should eq({ nil => pred }) } + it { + expect(subject).to eq({ nil => pred }) + } end context "on identifier" do let(:pred){ p.identifier(:x) } - it{ should eq({ x: pred }) } + it { + expect(subject).to eq({ x: pred }) + } end context "on not" do let(:pred){ p.not(:x) } - it{ should eq({ x: pred }) } + it { + expect(subject).to eq({ x: pred }) + } end context "on eq" do let(:pred){ p.eq(:x, 2) } - it{ should eq({ x: pred }) } + it { + expect(subject).to eq({ x: pred }) + } end context "on eq with placeholder" do let(:pred){ p.eq(:x, p.placeholder) } - it{ should eq({ x: pred }) } + it { + expect(subject).to eq({ x: pred }) + } end context "on in" do let(:pred){ p.in(:x, [2]) } - it{ should eq({ x: pred }) } + it { + expect(subject).to eq({ x: pred }) + } end context "on intersect" do let(:pred){ p.intersect(:x, [2]) } - it{ should eq({ x: pred }) } + it { + expect(subject).to eq({ x: pred }) + } end context "on subset" do let(:pred){ p.subset(:x, [2]) } - it{ should eq({ x: pred }) } + it { + expect(subject).to eq({ x: pred }) + } end context "on superset" do let(:pred){ p.superset(:x, [2]) } - it{ should eq({ x: pred }) } + it { + expect(subject).to eq({ x: pred }) + } end context "on match" do let(:pred){ p.match(:x, "London") } - it{ should eq({ x: pred }) } + it { + expect(subject).to eq({ x: pred }) + } end context "on match with two identifiers" do let(:pred){ p.match(:x, :y) } - it{ should eq({ nil => pred }) } + it { + expect(subject).to eq({ nil => pred }) + } end end diff --git a/spec/predicate/test_bool_and.rb b/spec/predicate/test_bool_and.rb index 91a691b..b7dc783 100644 --- a/spec/predicate/test_bool_and.rb +++ b/spec/predicate/test_bool_and.rb @@ -7,19 +7,23 @@ class Predicate subject{ left & right } before do - subject.should be_a(Predicate) + expect(subject).to be_a(Predicate) end context 'with itself' do let(:right){ left } - it{ should be(left) } + it { + expect(subject).to be(left) + } end context 'with the same expression' do let(:right){ Predicate.coerce(x: 2) } - it{ should be(left) } + it { + expect(subject).to be(left) + } end context 'with tautology' do diff --git a/spec/predicate/test_bool_not.rb b/spec/predicate/test_bool_not.rb index dbe53f9..51564c0 100644 --- a/spec/predicate/test_bool_not.rb +++ b/spec/predicate/test_bool_not.rb @@ -7,61 +7,81 @@ class Predicate context "on tautology" do let(:pred){ Predicate.tautology } - it{ should eq(Predicate.contradiction) } + it { + expect(subject).to eq(Predicate.contradiction) + } end context "on contradiction" do let(:pred){ Predicate.contradiction } - it{ should eq(Predicate.tautology) } + it { + expect(subject).to eq(Predicate.tautology) + } end context "on not" do let(:pred){ Predicate.not(:x) } - it{ should eq(Predicate.identifier(:x)) } + it { + expect(subject).to eq(Predicate.identifier(:x)) + } end context "on comp" do let(:pred){ Predicate.comp(:eq, :x => 2) } - it{ should eq(Predicate.comp(:neq, :x => 2)) } + it { + expect(subject).to eq(Predicate.comp(:neq, :x => 2)) + } end context "on eq" do let(:pred){ Predicate.eq(:x => 2) } - it{ should eq(Predicate.neq(:x => 2)) } + it { + expect(subject).to eq(Predicate.neq(:x => 2)) + } end context "on neq" do let(:pred){ Predicate.neq(:x => 2) } - it{ should eq(Predicate.eq(:x => 2)) } + it { + expect(subject).to eq(Predicate.eq(:x => 2)) + } end context "on lt" do let(:pred){ Predicate.lt(:x => 2) } - it{ should eq(Predicate.gte(:x => 2)) } + it { + expect(subject).to eq(Predicate.gte(:x => 2)) + } end context "on lte" do let(:pred){ Predicate.lte(:x => 2) } - it{ should eq(Predicate.gt(:x => 2)) } + it { + expect(subject).to eq(Predicate.gt(:x => 2)) + } end context "on gt" do let(:pred){ Predicate.gt(:x => 2) } - it{ should eq(Predicate.lte(:x => 2)) } + it { + expect(subject).to eq(Predicate.lte(:x => 2)) + } end context "on gte" do let(:pred){ Predicate.gte(:x => 2) } - it{ should eq(Predicate.lt(:x => 2)) } + it { + expect(subject).to eq(Predicate.lt(:x => 2)) + } end end diff --git a/spec/predicate/test_bool_or.rb b/spec/predicate/test_bool_or.rb index 82dca8b..16ec736 100644 --- a/spec/predicate/test_bool_or.rb +++ b/spec/predicate/test_bool_or.rb @@ -7,19 +7,23 @@ class Predicate subject{ left | right } before do - subject.should be_a(Predicate) + expect(subject).to be_a(Predicate) end context 'with itself' do let(:right){ left } - it{ should be(left) } + it { + expect(subject).to be(left) + } end context 'with the same expression' do let(:right){ Predicate.coerce(x: 2) } - it{ should be(left) } + it { + expect(subject).to be(left) + } end end diff --git a/spec/predicate/test_coerce.rb b/spec/predicate/test_coerce.rb index 5c6f1d9..7e9a383 100644 --- a/spec/predicate/test_coerce.rb +++ b/spec/predicate/test_coerce.rb @@ -7,39 +7,41 @@ class Predicate describe "from Predicate" do let(:arg){ Predicate.new(Factory.tautology) } - it{ should be(arg) } + it { + expect(subject).to be(arg) + } end describe "from true" do let(:arg){ true } - specify{ - subject.expr.should be_a(Tautology) + specify { + expect(subject.expr).to be_a(Tautology) } end describe "from false" do let(:arg){ false } - specify{ - subject.expr.should be_a(Contradiction) + specify { + expect(subject.expr).to be_a(Contradiction) } end describe "from Symbol" do let(:arg){ :status } - specify{ - subject.expr.should be_a(Identifier) - subject.expr.name.should eq(arg) + specify { + expect(subject.expr).to be_a(Identifier) + expect(subject.expr.name).to eq(arg) } end describe "from Proc" do let(:arg){ lambda{ status == 10 } } - specify{ - subject.expr.should be_a(Native) + specify { + expect(subject.expr).to be_a(Native) } end @@ -47,25 +49,25 @@ class Predicate let(:arg){ "status == 10" } it 'raises an error' do - lambda{ + expect{ subject - }.should raise_error(ArgumentError) + }.to raise_error(ArgumentError) end end describe "from Hash (single)" do let(:arg){ {status: 10} } - specify{ - subject.expr.should be_a(Eq) - subject.expr.should eq([:eq, [:identifier, :status], [:literal, 10]]) + specify { + expect(subject.expr).to be_a(Eq) + expect(subject.expr).to eq([:eq, [:identifier, :status], [:literal, 10]]) } end describe "from Hash (multiple)" do let(:arg){ {status: 10, name: "Jones"} } - specify{ + specify { expect(subject).to eq(Predicate.eq(status: 10) & Predicate.eq(name: "Jones")) } end @@ -73,7 +75,7 @@ class Predicate describe "from Hash (in)" do let(:arg){ {status: [10, 15]} } - specify{ + specify { expect(subject).to eq(Predicate.in(:status, [10,15])) } end diff --git a/spec/predicate/test_constants.rb b/spec/predicate/test_constants.rb index 5bfb1a8..ecd6173 100644 --- a/spec/predicate/test_constants.rb +++ b/spec/predicate/test_constants.rb @@ -8,157 +8,209 @@ class Predicate context "on tautology" do let(:pred){ p.tautology } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on contradiction" do let(:pred){ p.contradiction } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on eq(identifier,value)" do let(:pred){ p.eq(:x, 2) } - it{ should eq({x: 2}) } + it { + expect(subject).to eq({x: 2}) + } end context "on eq(identifier,placeholder)" do let(:pred){ p.eq(:x, p.placeholder) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on eq(value,identifier)" do let(:pred){ p.eq(2, :x) } - it{ should eq({x: 2}) } + it { + expect(subject).to eq({x: 2}) + } end context "on eq(identifier,identifier)" do let(:pred){ p.eq(:x, :y) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on not" do let(:pred){ !p.eq(:x, 2) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on neq" do let(:pred){ p.neq(:x, 2) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on gt" do let(:pred){ p.gt(:x, 2) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on in (singleton)" do let(:pred){ p.in(:x, [2]) } - it{ should eq({x: 2}) } + it { + expect(subject).to eq({x: 2}) + } end context "on in (multiples)" do let(:pred){ p.in(:x, [2, 3]) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on in (opaque)" do let(:pred){ p.in(:x, p.opaque([2])) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on and (two eqs)" do let(:pred){ p.eq(:x, 2) & p.eq(:y, 4) } - it{ should eq({x: 2, y: 4}) } + it { + expect(subject).to eq({x: 2, y: 4}) + } end context "on and (one eq)" do let(:pred){ p.eq(:x, 2) & p.in(:y, [4,8]) } - it{ should eq({x: 2}) } + it { + expect(subject).to eq({x: 2}) + } end context "on and (one eq, one in, same variable)" do let(:pred){ p.in(:x, [2,8]) & p.eq(:x, 2) } - it{ should eq({x: 2}) } + it { + expect(subject).to eq({x: 2}) + } end context "on and (one eq, one in, yielding contradiction)" do let(:pred){ p.in(:x, [3,8]) & p.eq(:x, 2) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on and (contradiction)" do let(:pred){ p.eq(:x, 2) & p.eq(:x, 4) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on intersect" do let(:pred){ p.intersect(:x, [4,8]) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on intersect with placeholder" do let(:pred){ p.intersect(:x, p.placeholder) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on subset" do let(:pred){ p.subset(:x, [4,8]) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on subset with placeholder" do let(:pred){ p.subset(:x, p.placeholder) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on superset" do let(:pred){ p.superset(:x, [4,8]) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on superset with placeholder" do let(:pred){ p.superset(:x, p.placeholder) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on or (two eqs)" do let(:pred){ p.eq(:x, 2) | p.eq(:y, 4) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on match" do let(:pred){ p.match(:x, "London") } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end context "on native" do let(:pred){ p.native(->(t){}) } - it{ should eq({}) } + it { + expect(subject).to eq({}) + } end end diff --git a/spec/predicate/test_free_variables.rb b/spec/predicate/test_free_variables.rb index 5eed984..6831ccb 100644 --- a/spec/predicate/test_free_variables.rb +++ b/spec/predicate/test_free_variables.rb @@ -7,7 +7,9 @@ class Predicate describe "on a comp(:eq)" do let(:p){ Predicate.coerce(:x => 2) } - it{ should eq([:x]) } + it { + expect(subject).to eq([:x]) + } end end diff --git a/spec/predicate/test_hash_and_equal.rb b/spec/predicate/test_hash_and_equal.rb index 9993586..5a3807e 100644 --- a/spec/predicate/test_hash_and_equal.rb +++ b/spec/predicate/test_hash_and_equal.rb @@ -5,21 +5,25 @@ class Predicate subject{ left == right } after do - left.hash.should eq(right.hash) if subject + expect(left.hash).to eq(right.hash) if subject end describe "on equal predicates" do let(:left) { Predicate.coerce(:x => 2) } let(:right){ Predicate.coerce(:x => 2) } - it{ should be(true) } + it { + expect(subject).to be(true) + } end describe "on non equal predicates" do let(:left) { Predicate.coerce(:x => 2) } let(:right){ Predicate.coerce(:x => 3) } - it{ should be(false) } + it { + expect(subject).to be(false) + } end end diff --git a/spec/predicate/test_qualify.rb b/spec/predicate/test_qualify.rb index 4afc9c0..0f7a843 100644 --- a/spec/predicate/test_qualify.rb +++ b/spec/predicate/test_qualify.rb @@ -24,12 +24,14 @@ class Predicate context 'on a full AST predicate' do let(:predicate){ p.in(:x, [2]) & p.eq(:y, 3) } - it{ should eq(p.in(Factory.qualified_identifier(:t, :x), [2]) & p.eq(:y, 3)) } + it { + expect(subject).to eq(p.in(Factory.qualified_identifier(:t, :x), [2]) & p.eq(:y, 3)) + } specify "it should tag expressions correctly" do - subject.expr.should be_a(Sexpr) - subject.expr.should be_a(Expr) - subject.expr.should be_a(And) + expect(subject.expr).to be_a(Sexpr) + expect(subject.expr).to be_a(Expr) + expect(subject.expr).to be_a(And) end end @@ -37,9 +39,9 @@ class Predicate let(:predicate){ p.in(:x, [2]) & p.native(lambda{}) } it 'raises an error' do - lambda{ + expect{ subject - }.should raise_error(NotSupportedError) + }.to raise_error(NotSupportedError) end end end diff --git a/spec/predicate/test_rename.rb b/spec/predicate/test_rename.rb index 62e7eab..ab97fd3 100644 --- a/spec/predicate/test_rename.rb +++ b/spec/predicate/test_rename.rb @@ -12,12 +12,14 @@ class Predicate context 'on a full AST predicate' do let(:predicate){ p.in(:x, [2]) & p.eq(:y, 3) } - it{ should eq(p.in(:z, [2]) & p.eq(:y, 3)) } + it { + expect(subject).to eq(p.in(:z, [2]) & p.eq(:y, 3)) + } specify "it should tag expressions correctly" do - subject.expr.should be_a(Sexpr) - subject.expr.should be_a(Expr) - subject.expr.should be_a(And) + expect(subject.expr).to be_a(Sexpr) + expect(subject.expr).to be_a(Expr) + expect(subject.expr).to be_a(And) end end @@ -25,9 +27,9 @@ class Predicate let(:predicate){ p.in(:x, [2]) & p.native(lambda{}) } it 'raises an error' do - lambda{ + expect{ subject - }.should raise_error(NotSupportedError) + }.to raise_error(NotSupportedError) end end @@ -35,7 +37,7 @@ class Predicate let(:predicate){ p.eq(Factory.qualified_identifier(:t, :x), 3) } it 'renames correctly' do - subject.should eq(p.eq(Factory.qualified_identifier(:t, :z), 3)) + expect(subject).to eq(p.eq(Factory.qualified_identifier(:t, :z), 3)) end end end @@ -46,13 +48,17 @@ class Predicate context "on an identifier" do let(:predicate){ p.eq(:x, 2) } - it{ should eq(p.eq(:y, 2)) } + it { + expect(subject).to eq(p.eq(:y, 2)) + } end context "on a qualifier identifier" do let(:predicate){ p.eq(Factory.qualified_identifier(:t, :x), 2) } - it{ should eq(p.eq(:y, 2)) } + it { + expect(subject).to eq(p.eq(:y, 2)) + } end end @@ -62,13 +68,17 @@ class Predicate context 'on an identifier' do let(:predicate){ p.eq(:x, 2) } - it{ should eq(p.eq(Factory.qualified_identifier(:t, :y), 2)) } + it { + expect(subject).to eq(p.eq(Factory.qualified_identifier(:t, :y), 2)) + } end context 'on a qualified' do let(:predicate){ p.eq(Factory.qualified_identifier(:t, :x), 2) } - it{ should eq(p.eq(Factory.qualified_identifier(:t, :y), 2)) } + it { + expect(subject).to eq(p.eq(Factory.qualified_identifier(:t, :y), 2)) + } end end diff --git a/spec/sequel/test_to_sequel.rb b/spec/sequel/test_to_sequel.rb index 5b9e36c..7368ee8 100644 --- a/spec/sequel/test_to_sequel.rb +++ b/spec/sequel/test_to_sequel.rb @@ -136,7 +136,6 @@ def o.sql_literal(db) let(:predicate) { Predicate.eq(:name, "Bob") & Predicate.eq(:price, 10.0) & Predicate.eq(:city, "London") } it 'works as expected' do - puts predicate.sexpr.inspect expect(subject).to eql("SELECT * FROM `items` WHERE ((`name` = 'Bob') AND (`price` = 10.0) AND (`city` = 'London'))") end end diff --git a/spec/shared/a_predicate.rb b/spec/shared/a_predicate.rb index ada4fa2..03fc040 100644 --- a/spec/shared/a_predicate.rb +++ b/spec/shared/a_predicate.rb @@ -5,30 +5,30 @@ let(:y){ 13 } it 'is a Predicate' do - subject.should be_a(Predicate) + expect(subject).to be_a(Predicate) end it 'can be negated easily' do - (!subject).should be_a(Predicate) + expect(!subject).to be_a(Predicate) end it 'detects stupid AND' do - (subject & Predicate.tautology).should be(subject) + expect(subject & Predicate.tautology).to be(subject) end it 'detects stupid OR' do - (subject | Predicate.contradiction).should be(subject) + expect(subject | Predicate.contradiction).to be(subject) end it 'has free variables' do - (fv = subject.free_variables).should be_a(Array) - (fv - [ :w, :x, :y ]).should be_empty + expect(fv = subject.free_variables).to be_a(Array) + expect(fv - [ :w, :x, :y ]).to be_empty end it 'always splits around and trivially when no free variables are touched' do top, down = subject.and_split([:z]) - top.should be_tautology - down.should eq(subject) + expect(top).to be_tautology + expect(down).to eq(subject) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 366dc22..80ba977 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -26,4 +26,5 @@ def create_items_database(db) RSpec.configure do |c| c.include Helpers c.extend Helpers + c.raise_errors_for_deprecations! end