Sha256: 7ccc266372047acee2aa9f650fcbb242a25d87399680a1be6b0852c5b2e2e7dd

Contents?: true

Size: 1.97 KB

Versions: 3

Compression:

Stored size: 1.97 KB

Contents

RSpec.describe Bluekai::Category, :vcr do
  include_context 'signature_mock'

  it 'reads a category and its reach' do
    read_response = subject.category_read(category_id: 421262, stats: 'True')
    expect(read_response).to include(
      name: 'Action',
      id: 421262,
      description: 'People who converted for Action games',
      leaf: true,
      parent_id: 421229
    )
    expect(read_response[:rules].size).to be > 0
  end

  it 'lists 4 categories' do
    list_response = subject.category_list(offset: 0, size: 4)
    expect(list_response.count).to eq(4)
    expect(list_response).to all(have_key(:name))
    expect(list_response).to all(have_key(:rules))
  end

  it 'creates a category' do
    category_body = {
      name: 'Test Category 123',
      parent_id: '424547',
      description: 'an example category',
      analytics_excluded: 'false',
      navigation_only: 'false',
      mutex_children: 'false',
      notes: 'Just an API test'
    }
    create_response = subject.category_create(category_body)
    expect(create_response).to include(
      name: 'Test Category 123',
      parent_id: 424547,
      description: 'an example category',
      analytics_excluded: false,
      navigation_only: false,
      mutex_children: false,
      notes: 'Just an API test'
    )
  end

  it 'updates a category' do
    category_update_body = {
      name: 'Test Category 321',
      description: 'an example category wohooo'
    }
    update_response = subject.category_update(424547, category_update_body)
    expect(update_response).to include(
      name: 'Test Category 321',
      description: 'an example category wohooo'
    )
  end

  it 'returns correct category ids' do
    green_id = subject.category_id(['BurtCorp - Private', 'Self-Classification', 'Green'])
    test_id = subject.category_id([
      'BurtCorp - Private',
      'Self-Classification',
      'a brand new one',
      'Test Category 123'])
    expect(green_id).to eq(314012)
    expect(test_id).to eq(425787)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bluekai-0.0.6 spec/lib/bluekai/category_integration_spec.rb
bluekai-0.0.5 spec/lib/bluekai/category_integration_spec.rb
bluekai-0.0.4 spec/lib/bluekai/category_integration_spec.rb