Sha256: 06f321a16ff4d7617c4567f6a5e840e097577104ea3c19958c80e08ad5898833

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

describe Unidom::Shopping::ShoppingItem, type: :model do

  before :each do
  end

  after :each do
  end

  context do

    model_attributes = {
      shopping_cart_id: SecureRandom.uuid,
      shopper_id:       SecureRandom.uuid,
      shopper_type:     'Unidom::Shopping::Shopper::Mock',
      shopped_id:       SecureRandom.uuid,
      shopped_type:     'Unidom::Shopping::Shopped::Mock',
      unit_price:       12.00,
      quantity:         5.00
    }

    it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes

    it_behaves_like 'validates numericality', model_attributes, :unit_price,
      range: 0..Unidom::Common::MAXIMUM_AMOUNT, minimum_inclusive: true, maximum_inclusive: true
    it_behaves_like 'validates numericality', model_attributes, :quantity,
      range: 0..Unidom::Common::MAXIMUM_AMOUNT, minimum_inclusive: true, maximum_inclusive: true

    shopping_cart_attributes = {
      shopper_id:   SecureRandom.uuid,
      shopper_type: 'Unidom::Shopping::Shopper',
      shop_id:      SecureRandom.uuid,
      shop_type:    'Unidom::Shopping::Shop'
    }

    it_behaves_like 'belongs_to', model_attributes, :shopping_cart, Unidom::Shopping::ShoppingCart, shopping_cart_attributes

    it_behaves_like 'monomorphic scope', model_attributes, :shopping_cart_is, :shopping_cart

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
unidom-shopping-2.0.1 lib/rspec/models/unidom/shopping/shopping_item_spec.rb
unidom-shopping-2.0 lib/rspec/models/unidom/shopping/shopping_item_spec.rb