Skip to content

Commit

Permalink
On #25: Moved auto conversion unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lentschi committed Dec 1, 2023
1 parent c56cf44 commit be321b0
Showing 1 changed file with 15 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
require_relative '../../spec/spec_helper'
require_relative '../migrate/20221026102301_alter_articles_add_more_unit_logic'

describe AlterArticlesAddMoreUnitLogic do
migration = nil
before do
migration = described_class.new
end
require_relative '../spec_helper'

describe ArticleUnitsLib do
it 'converts "kg" correctly' do
result = migration.send(:convert_old_unit, 'kg', 1)
result = described_class.convert_old_unit('kg', 1)
expect(result).to eq({
supplier_order_unit: 'KGM',
first_ratio: nil,
Expand All @@ -18,7 +12,7 @@
end

it 'converts "250g" correctly' do
result = migration.send(:convert_old_unit, '250g', 1)
result = described_class.convert_old_unit('250g', 1)
expect(result).to eq({
supplier_order_unit: 'XPP',
first_ratio: {
Expand All @@ -31,7 +25,7 @@
end

it 'converts "1/4 kg" correctly' do
result = migration.send(:convert_old_unit, '1/4 kg', 1)
result = described_class.convert_old_unit('1/4 kg', 1)
expect(result).to eq({
supplier_order_unit: 'XPP',
first_ratio: {
Expand All @@ -44,7 +38,7 @@
end

it 'converts "bunch" correctly' do
result = migration.send(:convert_old_unit, 'bunch', 1)
result = described_class.convert_old_unit('bunch', 1)
expect(result).to eq({
supplier_order_unit: 'XBH',
first_ratio: nil,
Expand All @@ -54,7 +48,7 @@
end

it 'converts "glass" correctly' do
result = migration.send(:convert_old_unit, 'glass', 1)
result = described_class.convert_old_unit('glass', 1)
expect(result).to eq({
supplier_order_unit: 'XGR',
first_ratio: nil,
Expand All @@ -64,7 +58,7 @@
end

it 'converts "piece" correctly' do
result = migration.send(:convert_old_unit, 'piece', 1)
result = described_class.convert_old_unit('piece', 1)
expect(result).to eq({
supplier_order_unit: 'XPP',
first_ratio: nil,
Expand All @@ -74,7 +68,7 @@
end

it 'converts "4 piece" correctly' do
result = migration.send(:convert_old_unit, '4 piece', 1)
result = described_class.convert_old_unit('4 piece', 1)
expect(result).to eq({
supplier_order_unit: 'XPK',
first_ratio: {
Expand All @@ -87,7 +81,7 @@
end

it 'converts "1 bunch" correctly' do
result = migration.send(:convert_old_unit, '1 bunch', 1)
result = described_class.convert_old_unit('1 bunch', 1)
expect(result).to eq({
supplier_order_unit: 'XBH',
first_ratio: nil,
Expand All @@ -97,7 +91,7 @@
end

it 'converts "2 bunch" correctly' do
result = migration.send(:convert_old_unit, '2 bunch', 1)
result = described_class.convert_old_unit('2 bunch', 1)
expect(result).to eq({
supplier_order_unit: 'XPK',
first_ratio: {
Expand All @@ -110,7 +104,7 @@
end

it 'converts "4x250g" correctly' do
result = migration.send(:convert_old_unit, '250g', 4)
result = described_class.convert_old_unit('250g', 4)
expect(result).to eq({
supplier_order_unit: 'XPP',
first_ratio: {
Expand All @@ -123,7 +117,7 @@
end

it 'converts "6 x glass" correctly' do
result = migration.send(:convert_old_unit, 'glass', 6)
result = described_class.convert_old_unit('glass', 6)
expect(result).to eq({
supplier_order_unit: 'XPK',
first_ratio: {
Expand All @@ -136,7 +130,7 @@
end

it 'fails to convert "12 nonesense"' do
result = migration.send(:convert_old_unit, '12 nonesense', 1)
expect(result).to eq(nil)
result = described_class.convert_old_unit('12 nonesense', 1)
expect(result).to be_nil
end
end

0 comments on commit be321b0

Please sign in to comment.