Sha256: 24977f2861d780753022b8069ecd312d1b37b5feb167408aaa47ce230d41d0b5

Contents?: true

Size: 1.96 KB

Versions: 50

Compression:

Stored size: 1.96 KB

Contents

require 'spec_helper'

describe Dugway::Drops::ProductOptionDrop do
  let(:product) { Dugway::Drops::ProductDrop.new(Dugway.store.products.first) }
  let(:option) { product.option }

  describe "#id" do
    it "should return the option's id" do
      option.id.should == 29474321
    end
  end

  describe "#name" do
    it "should return the option's name" do
      option.name.should == 'Small'
    end
  end

  describe "#price" do
    it "should return the option's price" do
      option.price.should == 10.0
    end
  end

  describe "#has_custom_price" do
    it "should return false when it has the same price" do
      option.has_custom_price.should be(false)
    end

    it "should return true when it has a different price" do
      option.stub(:price) { 25.0 }
      option.has_custom_price.should be(true)
    end
  end

  describe "#position" do
    it "should return the option's position" do
      option.position.should == 1
    end
  end

  describe "#sold" do
    it "should return a random number" do
      option.sold.should be >= 0
    end
  end

  describe "#sold_out" do
    it "should return whether the option's sold_out" do
      option.sold_out.should be(false)
    end
  end

  describe "#quantity" do
    it "should return a positivie random number if not sold_out" do
      option.quantity.should be >= 0
    end

    it "should return 0 when it is sold_out" do
      option.stub(:sold_out) { true }
      option.quantity.should be(0)
    end
  end

  describe "#inventory" do
    it "should return the option's calculated inventory" do
      option.stub(:quantity) { 25 }
      option.stub(:sold) { 75 }
      option.inventory.should be(25)
    end
  end

  describe "#default" do
    it "should true if it's the default option" do
      option.default.should be(true)
    end

    describe "when it's not the default option" do
      let(:option) { product.options.last }

      it "should return false" do
        option.default.should be(false)
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
dugway-1.0.14 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-1.0.13 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-1.0.12 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-1.0.10 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-1.0.9 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-1.0.8 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-1.0.7 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-1.0.6 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-1.0.5 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-1.0.4 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-1.0.3 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-1.0.2 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-1.0.1 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-1.0.0 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-0.12.3 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-0.12.2 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-0.12.1 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-0.12.0 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-0.11.4 spec/units/dugway/liquid/drops/product_option_drop_spec.rb
dugway-0.11.3 spec/units/dugway/liquid/drops/product_option_drop_spec.rb