spec/dentaku_spec.rb in dentaku-3.0.0 vs spec/dentaku_spec.rb in dentaku-3.1.0

- old
+ new

@@ -23,6 +23,17 @@ it 'raises a parse error for bad logic expressions' do expect { Dentaku('true AND') }.to raise_error(Dentaku::ParseError) end + + it 'evaluates with class-level shortcut functions' do + expect(Dentaku.evaluate('2+2')).to eq(4) + expect(Dentaku.evaluate!('2+2')).to eq(4) + expect { Dentaku.evaluate!('a+1') }.to raise_error(Dentaku::UnboundVariableError) + end + + it 'evaluates with class-level aliases' do + Dentaku.aliases = { roundup: ['roundupup'] } + expect(Dentaku.evaluate('roundupup(6.1)')).to eq(7) + end end