Sha256: b7af69c4b56c14e7caf07c442b06a87c1cf5656b793bebd67346d86cca269052
Contents?: true
Size: 1.14 KB
Versions: 16
Compression:
Stored size: 1.14 KB
Contents
require 'spec_helper' describe Spree::Price, :type => :model do describe 'validations' do let(:variant) { stub_model Spree::Variant } subject { Spree::Price.new variant: variant, amount: amount } context 'when the amount is nil' do let(:amount) { nil } it { is_expected.to be_valid } end context 'when the amount is less than 0' do let(:amount) { -1 } it 'has 1 error_on' do expect(subject.error_on(:amount).size).to eq(1) end it 'populates errors' do subject.valid? expect(subject.errors.messages[:amount].first).to eq 'must be greater than or equal to 0' end end context 'when the amount is greater than 999,999.99' do let(:amount) { 1_000_000 } it 'has 1 error_on' do expect(subject.error_on(:amount).size).to eq(1) end it 'populates errors' do subject.valid? expect(subject.errors.messages[:amount].first).to eq 'must be less than or equal to 999999.99' end end context 'when the amount is between 0 and 999,999.99' do let(:amount) { 100 } it { is_expected.to be_valid } end end end
Version data entries
16 entries across 16 versions & 1 rubygems