177177 matcher = described_class . new ( segments_repository , rbs_repositoy , 'sample_rule_based_segment' , config )
178178 expect ( matcher . match? ( value : 'bilal@split.io' , attributes : { 'email' : 'bilal@split.io' } ) ) . to be true
179179 expect ( matcher . match? ( value : 'bilal' , attributes : { 'email' : 'bilal' } ) ) . to be false
180- end
180+ end
181+
182+ it 'return true if has multiple conditions' do
183+ rbs_repositoy = SplitIoClient ::Cache ::Repositories ::RuleBasedSegmentsRepository . new ( config )
184+ rbs = {
185+ :name => 'sample_rule_based_segment' ,
186+ :trafficTypeName => 'tt_name_1' ,
187+ :conditions => [
188+ {
189+ :matcherGroup => {
190+ :combiner => "AND" ,
191+ :matchers => [
192+ {
193+ :matcherType => "WHITELIST" ,
194+ :negate => false ,
195+ :userDefinedSegmentMatcherData => nil ,
196+ :whitelistMatcherData => {
197+ :whitelist => [
198+ "bilal"
199+ ]
200+ } ,
201+ :unaryNumericMatcherData => nil ,
202+ :betweenMatcherData => nil
203+ }
204+ ]
205+ }
206+ } ,
207+ {
208+ :matcherGroup => {
209+ :combiner => "AND" ,
210+ :matchers => [
211+ {
212+ :matcherType => "WHITELIST" ,
213+ :negate => false ,
214+ :userDefinedSegmentMatcherData => nil ,
215+ :whitelistMatcherData => {
216+ :whitelist => [
217+ "mauro"
218+ ]
219+ } ,
220+ :unaryNumericMatcherData => nil ,
221+ :betweenMatcherData => nil
222+ }
223+ ]
224+ }
225+ }
226+ ] ,
227+ :excluded => { :keys => [ ] , :segments => [ ] }
228+ }
229+
230+ rbs_repositoy . update ( [ rbs ] , [ ] , -1 )
231+ matcher = described_class . new ( segments_repository , rbs_repositoy , 'sample_rule_based_segment' , config )
232+ expect ( matcher . match? ( value : 'mauro' , attributes : { } ) ) . to be true
233+ expect ( matcher . match? ( value : 'bilal' , attributes : { } ) ) . to be true
234+ expect ( matcher . match? ( value : 'nicolas' , attributes : { } ) ) . to be false
235+ end
181236 end
182237end
0 commit comments