Sha256: 0b5af4b7984774df30dc926c539738303f9a54ae24919a980bcb71b462df3845

Contents?: true

Size: 1.61 KB

Versions: 4

Compression:

Stored size: 1.61 KB

Contents

require 'spec_helper'

describe Reviewed::Product do

  describe 'associations' do

    describe 'attachments' do
      use_vcr_cassette 'product/attachments'

      before(:each) do
        @product = Reviewed::Product.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 = Reviewed::Product.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

4 entries across 4 versions & 1 rubygems

Version Path
reviewed-0.1.2 spec/product_spec.rb
reviewed-0.1.1 spec/product_spec.rb
reviewed-0.1.0 spec/product_spec.rb
reviewed-0.0.9 spec/product_spec.rb