spec/unit/operations/and_spec.rb in dry-logic-0.5.0 vs spec/unit/operations/and_spec.rb in dry-logic-0.6.0

- old
+ new

@@ -1,12 +1,12 @@ RSpec.describe Operations::And do subject(:operation) { Operations::And.new(left, right) } include_context 'predicates' - let(:left) { Rule::Predicate.new(int?) } - let(:right) { Rule::Predicate.new(gt?).curry(18) } + let(:left) { Rule::Predicate.build(int?) } + let(:right) { Rule::Predicate.build(gt?).curry(18) } describe '#call' do it 'calls left and right' do expect(operation.(18)).to be_failure end @@ -22,10 +22,14 @@ it 'returns result ast' do expect(operation.('18').to_ast).to eql( [:and, [[:predicate, [:int?, [[:input, '18']]]], [:hint, [:predicate, [:gt?, [[:num, 18], [:input, '18']]]]]]] ) + expect(operation.with(hints: false).('18').to_ast).to eql( + [:predicate, [:int?, [[:input, '18']]]] + ) + expect(operation.(18).to_ast).to eql( [:predicate, [:gt?, [[:num, 18], [:input, 18]]]] ) end @@ -39,18 +43,18 @@ ) end end describe '#and' do - let(:other) { Rule::Predicate.new(lt?).curry(30) } + let(:other) { Rule::Predicate.build(lt?).curry(30) } it 'creates and with the other' do expect(operation.and(other).(31)).to be_failure end end describe '#or' do - let(:other) { Rule::Predicate.new(lt?).curry(14) } + let(:other) { Rule::Predicate.build(lt?).curry(14) } it 'creates or with the other' do expect(operation.or(other).(13)).to be_success end end