1
0

Add integration spec

This commit is contained in:
Tim Kächele 2024-08-25 10:09:43 +02:00
parent 5a208803b3
commit 74fc3284bf
5 changed files with 65 additions and 5 deletions

View File

@ -10,3 +10,5 @@ gem "rake", "~> 13.0"
gem "rspec", "~> 3.0" gem "rspec", "~> 3.0"
gem "standard", "~> 1.3" gem "standard", "~> 1.3"
gem "simplecov", "~> 0.22.0"

20
spec/fixtures/input.txt vendored Normal file
View File

@ -0,0 +1,20 @@
2015-02-01 S MR
2015-02-02 S MR
2015-02-03 L LP
2015-02-05 S LP
2015-02-06 S MR
2015-02-06 L LP
2015-02-07 L MR
2015-02-08 M MR
2015-02-09 L LP
2015-02-10 L LP
2015-02-10 S MR
2015-02-10 S MR
2015-02-11 L LP
2015-02-12 M MR
2015-02-13 M LP
2015-02-15 S MR
2015-02-17 L LP
2015-02-17 S MR
2015-02-24 L LP
2015-03-01 S MR

20
spec/fixtures/output.txt vendored Normal file
View File

@ -0,0 +1,20 @@
2015-02-01 S MR 1.50 0.50
2015-02-02 S MR 1.50 0.50
2015-02-03 L LP 6.90 -
2015-02-05 S LP 1.50 -
2015-02-06 S MR 1.50 0.50
2015-02-06 L LP 6.90 -
2015-02-07 L MR 4.00 -
2015-02-08 M MR 3.00 -
2015-02-09 L LP 0.00 6.90
2015-02-10 L LP 6.90 -
2015-02-10 S MR 1.50 0.50
2015-02-10 S MR 1.50 0.50
2015-02-11 L LP 6.90 -
2015-02-12 M MR 3.00 -
2015-02-13 M LP 4.90 -
2015-02-15 S MR 1.50 0.50
2015-02-17 L LP 6.90 -
2015-02-17 S MR 1.90 0.10
2015-02-24 L LP 6.90 -
2015-03-01 S MR 1.50 0.50

View File

@ -1,11 +1,25 @@
# frozen_string_literal: true # frozen_string_literal: true
RSpec.describe PlanetExpressExpress do RSpec.describe PlanetExpressExpress do
it "has a version number" do it "calculates the shipment discounts and formats them properly" do
expect(PlanetExpressExpress::VERSION).not_to be nil input_file = File.open(
end File.expand_path("../fixtures/input.txt", __FILE__),
"r"
)
it "does something useful" do shipments = PlanetExpressExpress::ShipmentReader.new(PlanetExpressExpress::PRICE_LIST).read_shipments(input_file)
expect(false).to eq(true) PlanetExpressExpress::Rules.new(PlanetExpressExpress::PRICE_LIST).apply_rules(shipments)
PlanetExpressExpress::DiscountBudget.new(PlanetExpressExpress::DISCOUNT_LIMIT).limit_discounts(shipments)
output = StringIO.new
PlanetExpressExpress::Formatter.new(output).format(shipments)
expected_output = File.read(
File.expand_path("../fixtures/output.txt", __FILE__),
)
output.rewind
expect(output.read).to match(expected_output)
end end
end end

View File

@ -1,5 +1,9 @@
# frozen_string_literal: true # frozen_string_literal: true
require "simplecov"
SimpleCov.start do
enable_coverage :branch
end
require "planet_express_express" require "planet_express_express"
RSpec.configure do |config| RSpec.configure do |config|