Sha256: fc1d7712b88089633600e18ec94778c88f6a2db0b843d6200716740d03fa94e0
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
require 'rspec' require 'faker' require_relative '../lib/philtre/predicate_splitter.rb' # for blank? Sequel.extension :blank describe Philtre::PredicateSplitter do describe '#split_key' do describe 'successful' do let(:splitter){ Philtre::PredicateSplitter.new( 'birth_year_like', 'fifteeen' ) } it 'returns true' do splitter.split_key( :like ).should be_truthy end it 'keeps field as symbol' do splitter.split_key :like splitter.field.should == :birth_year end it 'keeps op as symbol' do splitter.split_key :like splitter.op.should == :like end end describe 'unsuccessful' do let(:splitter){ Philtre::PredicateSplitter.new 'birth_year', 'fifteeen' } it 'returns false' do splitter.split_key( :like ).should be_falsey end it 'keeps key as symbol' do splitter.split_key :like splitter.field.should == :birth_year end it 'op is nil' do splitter.split_key :like splitter.op.should be_nil end end describe 'custom predicate' do let(:splitter){ Philtre::PredicateSplitter.new( 'custom_predicate', 'fifteeen' ) } it 'accepts the whole thing' do (splitter === :custom_predicate).should === 0 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
philtre-0.1.0 | spec/predicate_splitter_spec.rb |
philtre-0.0.1 | spec/predicate_splitter_spec.rb |