Sha256: 02f7eccd9031ab74f556cc26c2d24800b6e30cd07c895ca6fa98a569b5b7b89a
Contents?: true
Size: 1.72 KB
Versions: 1
Compression:
Stored size: 1.72 KB
Contents
# frozen_string_literal: true require 'spec_helper' RSpec.describe SolidusEasypost::ParcelDimension do describe '.new' do subject(:instance) { described_class.new(params) } let(:params) do { height: 3 } end context 'when the weight is not passed' do let(:params) do { height: 3 } end it 'raises an argument error exception' do expect { instance }.to raise_error(ArgumentError) end end context 'when the passed weight is zero' do let(:params) do { height: 3, weight: 0 } end it 'raises an argument error exception' do expect { instance }.to raise_error(ArgumentError) end end end describe '#to_h' do subject(:instance_hash) { described_class.new(params).to_h } context 'when the params contains zero values' do let(:params) do { weight: 3, width: 0, height: 0, unknown: -1 } end it 'returns the correct parcel dimension hash' do expect(instance_hash).to eq({ weight: 3 }) end end context 'when the params contains the wrong params' do let(:params) do { weight: 3, unknown: -1, another: 11 } end it 'returns the correct parcel dimension hash' do expect(instance_hash).to eq({ weight: 3 }) end end context 'when the params contains the correct params' do let(:params) do { weight: 3, width: 1, depth: 6, height: 11 } end it 'returns the correct parcel dimension hash' do expect(instance_hash).to eq({ height: 11, weight: 3, width: 1, length: 6, }) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solidus_easypost-3.0.0 | spec/models/solidus_easypost/parcel_dimension_spec.rb |