Sha256: 6738d38a132c504dd48eb06d4741cffa9eeb8f67854e40e5e5b62878aff9f404
Contents?: true
Size: 1.54 KB
Versions: 7
Compression:
Stored size: 1.54 KB
Contents
require 'spec_helper' class Predicate describe Predicate, "evaluate" do context 'on a native predicate of arity 1, used through tuple#[]' do let(:predicate){ Predicate.native(->(t){ t[:name] =~ /foo/ }) } context 'on a matching tuple' do let(:scope){ { :name => "foo" } } it{ expect(predicate.evaluate(scope)).to be_truthy } end context 'on a non-matching tuple' do let(:scope){ { :name => "bar" } } it{ expect(predicate.evaluate(scope)).to be_falsy } end end context 'on a native predicate of arity 1, used through tuple[:xxx]' do let(:predicate){ Predicate.native(->(t){ t[:name] =~ /foo/ }) } context 'on a matching tuple' do let(:scope){ { :name => "foo" } } it{ expect(predicate.evaluate(scope)).to be_truthy } end context 'on a non-matching tuple' do let(:scope){ { :name => "bar" } } it{ expect(predicate.evaluate(scope)).to be_falsy } end end context 'on a factored predicate' do let(:predicate){ Predicate.new(Factory.lte(:x => 2)) } describe "on x == 2" do let(:scope){ { :x => 2 } } it{ expect(predicate.evaluate(scope)).to be_truthy } end describe "on x == 1" do let(:scope){ { :x => 1 } } it{ expect(predicate.evaluate(scope)).to be_truthy } end describe "on x == 3" do let(:scope){ { :x => 3 } } it{ expect(predicate.evaluate(scope)).to be_falsy } end end end end
Version data entries
7 entries across 7 versions & 1 rubygems