Sha256: 8cddb93004b967e24a083f4e6eb92e22ae705f77c46e0cd26b9e481dc905a464

Contents?: true

Size: 1.68 KB

Versions: 7

Compression:

Stored size: 1.68 KB

Contents

require 'spec_helper'

describe Reviewed::Product do

  let(:client) do
    Reviewed::Client.new(api_key: TEST_KEY, base_uri: TEST_URL)
  end

  describe 'associations' do

    describe 'attachments', vcr: true do

      before(:each) do
        Reviewed::Cache.store.clear
        @product = client.products.with_no_cache.find('minden-master-ii')
      end

      it 'no longer has_many :attachments' do
        Reviewed::Product._embedded_many.should_not include({"attachments"=>Reviewed::Attachment})
      end

      it 'returns attachments of the correct class' do
        @product.attachments(:gallery).each do |attachment|
          attachment.should be_an_instance_of(Reviewed::Attachment)
        end
      end

      it 'returns attachments by tag' do
        @product.attachments(:vanity).length.should == 1
      end

      it 'matches attachments by tag properly' do
        attachments = @product.attachments('vanity')
        attachments.each do |attachment|
          attachment.tags.join(',').should match(/vanity/i)
        end
      end

      it 'does not have any matching attachments' do
        attachments = @product.attachments('doesnotcompute')
        attachments.length.should == 0
      end
    end
  end

  describe 'manufacturer_specs', vcr: true do

    before(:each) do
      @product = client.products.find('minden-master-ii')
    end

    it 'has_many :manufacturer_specs' do
      Reviewed::Product._embedded_many.should include({"manufacturer_specs"=>Reviewed::ManufacturerSpec})
    end

    it 'returns attachments of the correct class' do
      @product.manufacturer_specs.each do |ms|
        ms.should be_an_instance_of(Reviewed::ManufacturerSpec)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
reviewed-0.8.0 spec/product_spec.rb
reviewed-0.7.1 spec/product_spec.rb
reviewed-0.7 spec/product_spec.rb
reviewed-0.6.4 spec/product_spec.rb
reviewed-0.6.3 spec/product_spec.rb
reviewed-0.6.2 spec/product_spec.rb
reviewed-0.6.1 spec/product_spec.rb