Sha256: 6b78ffa4bf93ae6432b779604869c7f91272dfa14900b6a985f4a43175f608f7
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
require 'spec_helper' require 'dentaku/ast/functions/all' require 'dentaku' describe Dentaku::AST::All do let(:calculator) { Dentaku::Calculator.new } it 'performs ALL operation' do result = Dentaku('ALL(vals, val, val > 1)', vals: [1, 2, 3]) expect(result).to eq(false) end it 'works with a single value if needed for some reason' do result = Dentaku('ALL(vals, val, val > 1)', vals: 1) expect(result).to eq(false) result = Dentaku('ALL(vals, val, val > 1)', vals: 2) expect(result).to eq(true) end it 'raises argument error if a string is passed as identifier' do expect { calculator.evaluate!('ALL({1, 2, 3}, "val", val % 2 == 0)') }.to raise_error( Dentaku::ParseError, 'ALL() requires second argument to be an identifier' ) end it 'treats missing keys in hashes as NULL in permissive mode' do expect( calculator.evaluate('ALL(items, item, item.value)', items: [{value: 1}, {}]) ).to be_falsy end it 'raises an error if accessing a missing key in a hash in strict mode' do expect { calculator.evaluate!('ALL(items, item, item.value)', items: [{value: 1}, {}]) }.to raise_error(Dentaku::UnboundVariableError) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dentaku-3.5.4 | spec/ast/all_spec.rb |