1
0

Add inspection methods to shipping option

This commit is contained in:
Tim Kächele 2021-03-07 18:55:34 +01:00
parent a0ab3cc6da
commit 86dffbc8fe
2 changed files with 48 additions and 1 deletions

View File

@ -1,5 +1,17 @@
# frozen_string_literal: true # frozen_string_literal: true
module PlanetExpress module PlanetExpress
ShippingOption = Struct.new(:provider, :package_size, :price_in_cents) ShippingOption = Struct.new(:provider, :package_size, :price_in_cents) do
def s_shipment?
package_size == 'S'
end
def l_shipment?
package_size == 'L'
end
def inspect
"ShippingOption [proivder=#{provider} package_size=#{package_size} price_in_cents=#{price_in_cents}]"
end
end
end end

View File

@ -0,0 +1,35 @@
# frozen_string_literal: true
RSpec.describe PlanetExpress::ShippingOption do
describe '#s_shipment?' do
context 'with S package size' do
subject { build(:shipping_option, package_size: 'S') }
it 'returns true' do
expect(subject.s_shipment?).to eq(true)
end
end
context 'with non S package size' do
subject { build(:shipping_option, package_size: 'M') }
it 'returns false' do
expect(subject.s_shipment?).to eq(false)
end
end
end
describe '#l_shipment?' do
context 'with L package size' do
subject { build(:shipping_option, package_size: 'L') }
it 'returns true' do
expect(subject.l_shipment?).to eq(true)
end
end
context 'with non L package size' do
subject { build(:shipping_option, package_size: 'M') }
it 'returns false' do
expect(subject.l_shipment?).to eq(false)
end
end
end
end