From d82a6d1311ad72dc5a534b982f210f7180cdaeb1 Mon Sep 17 00:00:00 2001 From: mms Date: Fri, 8 Nov 2024 22:27:44 +0100 Subject: fix: parens in filters --- spec/messages_spec.rb | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/messages_spec.rb b/spec/messages_spec.rb index de8b393..6a84bc3 100644 --- a/spec/messages_spec.rb +++ b/spec/messages_spec.rb @@ -38,19 +38,34 @@ RSpec.describe Some::Messages do describe 'hash filters' do context 'with singular values' do - it { expect(subject.filter(from: 'baltar@battlestar.com').query_string).to eq('( (from:baltar@battlestar.com))') } + it { expect(subject.filter(from: 'baltar@battlestar.com').query_string).to eq(' (from:baltar@battlestar.com)') } it { expect(subject.filter(from: 'baltar@battlestar.com', ship: 'galactica').query_string) - .to eq('( (from:baltar@battlestar.com) and (ship:galactica))') + .to eq(' (from:baltar@battlestar.com) and (ship:galactica)') + } + + it { + expect(subject.or.filter(from: 'baltar@battlestar.com', ship: 'galactica').query_string) + .to eq(' (from:baltar@battlestar.com) or (ship:galactica)') } end context 'with set of values' do it { expect(subject.filter(from: ['baltar@battlestar.com', - 'adama@battestar.com']).query_string).to eq('(( (from:baltar@battlestar.com) or (from:adama@battestar.com)))') + 'adama@battestar.com']).query_string) + .to eq(' (from:baltar@battlestar.com) or (from:adama@battestar.com)') } end end + + context 'advanced filters' do + it { + expect(subject.filter(from: ['baltar@battlestar.com', 'adama@battestar.com']) + .and.filter(ship: 'battlestar') + .or.filter(ship: 'pegasus').query_string) + .to eq(' (from:baltar@battlestar.com) or (from:adama@battestar.com) and (ship:battlestar) or (ship:pegasus)') + } + end end -- cgit v1.2.3