|
9 | 9 | id: 1,
|
10 | 10 | name: 'Test #1',
|
11 | 11 |
|
| 12 | + contact_id: '1', |
12 | 13 | schedule: { all_day: true, opened: true },
|
13 | 14 | numbers: %w[1 2],
|
14 | 15 | phones: [
|
|
22 | 23 | id: 2,
|
23 | 24 | name: 'Test #2',
|
24 | 25 |
|
| 26 | + contact_id: '2', |
25 | 27 | schedule: { all_day: false, opened: false },
|
26 | 28 | numbers: %w[3 4],
|
27 | 29 | phones: [],
|
|
32 | 34 | id: 3,
|
33 | 35 | name: 'Test #3',
|
34 | 36 |
|
| 37 | + contact_id: '', |
35 | 38 | schedule: { all_day: false, opened: false },
|
36 | 39 | numbers: %w[5 6],
|
37 | 40 | phones: [
|
|
44 | 47 | end
|
45 | 48 |
|
46 | 49 | context 'Deep values' do
|
| 50 | + context 'ex' do |
| 51 | + it 'if the value is not empty' do |
| 52 | + filters = { 'phones.number': { ex: 'true' } } |
| 53 | + |
| 54 | + collection = described_class.swap(data, filters) |
| 55 | + |
| 56 | + expect(collection.size).to eq(2) |
| 57 | + end |
| 58 | + |
| 59 | + it 'if the value is not empty' do |
| 60 | + filters = { 'phones.number': { not_ex: 'true' } } |
| 61 | + |
| 62 | + collection = described_class.swap(data, filters) |
| 63 | + |
| 64 | + expect(collection.size).to eq(1) |
| 65 | + end |
| 66 | + |
| 67 | + it 'if the value is not empty' do |
| 68 | + filters = { contact_id: { ex: 'true' } } |
| 69 | + |
| 70 | + collection = described_class.swap(data, filters) |
| 71 | + |
| 72 | + expect(collection.size).to eq(2) |
| 73 | + end |
| 74 | + |
| 75 | + it 'if the value is empty' do |
| 76 | + filters = { contact_id: { not_ex: 'true' } } |
| 77 | + |
| 78 | + collection = described_class.swap(data, filters) |
| 79 | + |
| 80 | + expect(collection.size).to eq(1) |
| 81 | + end |
| 82 | + end |
| 83 | + |
47 | 84 | context 'eq' do
|
48 | 85 | context 'array of hash' do
|
49 | 86 | it 'match array values in deep structure' do
|
|
0 commit comments