RSpec.describe Bluekai::Rule, :vcr do include_context 'signature_mock' it 'creates a rule' do rule_body = { name: 'CONVERSION_TEST_1234', type: 'phint', phints: [{ key: 'offer_id', value: 321, operator: 'is' }], category_ids: [421262], site_ids: [23705] } create_response = subject.rule_create(rule_body) expect(create_response).to include( name: 'CONVERSION_TEST_1234', type: 'phint', status: 'active', phints: [{ id: 24110, key: 'offer_id', value: '321', operator: 'is' }], categories: [{ id: 421262, name: 'Action' }], sites: [{ id: 23705, name: 'Cake - Data Collection Tag' }] ) end it 'updates a rule' do update_body = { name: 'CONVERSION_TEST_321', type: 'phint', phints: [{ key: 'offer_id', value: 321, operator: 'contains' }], category_ids: [421262], site_ids: [23705] } update_response = subject.rule_update(12490, update_body) expect(update_response).to include( name: 'CONVERSION_TEST_321', type: 'phint', status: 'active', phints: [{ id: 24099, key: 'offer_id', value: '321', operator: 'contains' }], categories: [{ id: 421262, name: 'Action' }] ) end it 'reads a rule' do read_response = subject.rule_read(10380) expect(read_response).to include( categories: [{ id: 421427, name: 'Simulation' }, { id: 421262, name: 'Action' }], created_at: 'Thu Apr 02 09:50:57 EDT 2015', id: 10380, name: 'CONVERSION_ACTION_SIMULATION_9126', phints: [{ id: 14420, key: 'offer_id', value: '9126', operator: 'is' }, { id: 17150, key: 'event', value: 'conversion', operator: 'is' }], status: 'active', type: 'phint' ) end it 'lists 10 phint rules' do rule_list = subject.rule_list(offset: 0, size: 10, type: 'phint') expect(rule_list.count).to eq(10) expect(rule_list).to all(include( type: 'phint' )) end it 'it creates a rule and deletes it' do rule_body = { name: 'TEST_123', type: 'phint', phints: [{ key: 'offer_id', value: 321, operator: 'is' }] } create_response = subject.rule_create(rule_body) rule_id = create_response[:id] expect(subject.rule_delete(rule_id)).to eq(:success) end end