Sha256: 0e40e19c4e253104e696a2c89a1933bf632c2a74d85ad6dd022a423f1b08adbb

Contents?: true

Size: 1.69 KB

Versions: 9

Compression:

Stored size: 1.69 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' do
      use_vcr_cassette 'product/attachments'

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

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

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

      it 'returns all attachments' do
        @product.attachments.length.should == 1
      end

      it 'finds attachments by tag' do
        attachments = @product.attachments('vanity')
        attachments.length.should == 1
        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' do
    use_vcr_cassette 'product/manufacturer_specs'

    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

9 entries across 9 versions & 1 rubygems

Version Path
reviewed-0.1.29 spec/product_spec.rb
reviewed-0.1.28 spec/product_spec.rb
reviewed-0.1.27 spec/product_spec.rb
reviewed-0.1.26 spec/product_spec.rb
reviewed-0.1.25 spec/product_spec.rb
reviewed-0.1.24 spec/product_spec.rb
reviewed-0.1.23 spec/product_spec.rb
reviewed-0.1.22 spec/product_spec.rb
reviewed-0.1.21 spec/product_spec.rb