Sha256: 0480ce353095baac8bf153c54f7bc6de87b4c92a854def53caafd6cba96a6abc

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 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',
      shopped_id:       SecureRandom.uuid,
      shopped_type:     'Unidom::Shopping::Shopped',
      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..1_000_000_000, minimum_inclusive: true, maximum_inclusive: true
    it_behaves_like 'validates numericality', model_attributes, :quantity,
      range: 0..1_000_000_000, 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-1.7.5 lib/rspec/models/unidom/shopping/shopping_item_spec.rb
unidom-shopping-1.7.4 lib/rspec/models/unidom/shopping/shopping_item_spec.rb