# frozen_string_literal: true require 'rspec' require_relative '../lib/some/messages' RSpec.describe Some::Messages do let(:subject) { Some::Messages.new } describe 'direct filters' 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').filter('ship:galactica').query_string) .to eq(' (from:baltar@battlestar.com) and (ship:galactica)') } end describe 'conjuction change' do it { expect(subject.filter('from:baltar@battlestar.com') .or.filter('ship:galactica').query_string).to eq(' (from:baltar@battlestar.com) or (ship:galactica)') } it { expect(subject.filter('from:baltar@battlestar.com') .or.filter('ship:galactica') .filter('hair:long').query_string) .to eq(' (from:baltar@battlestar.com) or (ship:galactica) or (hair:long)') } it { expect(subject.filter('from:baltar@battlestar.com') .or.filter('ship:galactica') .and.filter('hair:long').query_string) .to eq(' (from:baltar@battlestar.com) or (ship:galactica) and (hair:long)') } end 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', ship: 'galactica').query_string) .to eq('( (from:baltar@battlestar.com) and (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)))') } end end end