Sha256: 9d691c0a1dbd3ed73984675ecbe7e218d5071ab2434f43159f36b4b87cc35b32

Contents?: true

Size: 1.27 KB

Versions: 8

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'

# rspec spec/tophatter_merchant/variation_spec.rb
describe TophatterMerchant::Variation do
  describe '.schema', :vcr do
    it 'returns the schema' do
      schema = TophatterMerchant::Variation.schema
      expect(schema.find { |component| component['field'] == 'identifier' }['name']).to eq('Variation Unique ID (SKU)')
    end
  end

  describe '.retrieve' do
    it 'retrieves a variation', :vcr do
      variation = TophatterMerchant::Variation.retrieve('CT1-S')
      expect(variation.identifier).to eq('CT1-S')
      expect(variation.size).to eq('S')
    end
  end

  describe '.create' do
    it 'creates a variation', :vcr do
      variation = TophatterMerchant::Variation.create(
        product_identifier: 'C-T-1',
        identifier: 'CT1-M',
        size: 'M',
        quantity: 99
      )
      expect(variation.identifier).to eq('CT1-M')
      expect(variation.size).to eq('M')
      expect(variation.quantity).to eq(99)
    end
  end

  describe '.update' do
    it 'updates a variation', :vcr do
      variation = TophatterMerchant::Variation.update('CT1-S', quantity: 99)
      expect(variation.quantity).to eq(99)
      variation = TophatterMerchant::Variation.update('CT1-S', quantity: 999)
      expect(variation.quantity).to eq(999)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tophatter-merchant-1.2.2 spec/tophatter_merchant/variation_spec.rb
tophatter-merchant-1.2.1 spec/tophatter_merchant/variation_spec.rb
tophatter-merchant-1.2.0 spec/tophatter_merchant/variation_spec.rb
tophatter-merchant-1.1.9 spec/tophatter_merchant/variation_spec.rb
tophatter-merchant-1.1.8 spec/tophatter_merchant/variation_spec.rb
tophatter-merchant-1.1.7 spec/tophatter_merchant/variation_spec.rb
tophatter-merchant-1.1.6 spec/tophatter_merchant/variation_spec.rb
tophatter-merchant-1.1.5 spec/tophatter_merchant/variation_spec.rb