From 87e523a53bff70ae1af8140c796c0250a06b9d4b Mon Sep 17 00:00:00 2001 From: Shesh Santosh Date: Fri, 14 Feb 2025 17:16:48 +0530 Subject: [PATCH] updated edge cases in test files --- ruby/gilded_rose_spec.rb | 21 +++++++++++++++++++-- ruby/texttest_fixture.rb | 7 ++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/ruby/gilded_rose_spec.rb b/ruby/gilded_rose_spec.rb index fbd084e7..f36b83b6 100644 --- a/ruby/gilded_rose_spec.rb +++ b/ruby/gilded_rose_spec.rb @@ -37,12 +37,17 @@ describe GildedRose do it "checks for quality to never be less than 0" do update_and_check_item(item_name: "+5 Dexterity Vest", initial_sell_in: 10, initial_quant: 0, output: "+5 Dexterity Vest, 9, 0") end + + it "when sell_in value is negative" do + update_and_check_item(item_name: "+5 Dexterity Vest", initial_sell_in: -1, initial_quant: 8, output: "+5 Dexterity Vest, -2, 6") + end end context "Sulfuras, Hand of Ragnaros" do it "never changes it's sell_in value and quantity" do update_and_check_item(item_name: "Sulfuras, Hand of Ragnaros", initial_sell_in: 0, initial_quant: 80, output: "Sulfuras, Hand of Ragnaros, 0, 80") update_and_check_item(item_name: "Sulfuras, Hand of Ragnaros", initial_sell_in: -1, initial_quant: 80, output: "Sulfuras, Hand of Ragnaros, -1, 80") + update_and_check_item(item_name: "Sulfuras, Hand of Ragnaros", initial_sell_in: 1, initial_quant: 80, output: "Sulfuras, Hand of Ragnaros, 1, 80") end end @@ -58,6 +63,10 @@ describe GildedRose do it "checks for quality to never be more than 50" do update_and_check_item(item_name: "Aged Brie", initial_sell_in: 10, initial_quant: 50, output: "Aged Brie, 9, 50") end + + it "when sell_in value is negative" do + update_and_check_item(item_name: "Aged Brie", initial_sell_in: -1, initial_quant: 20, output: "Aged Brie, -2, 22") + end end @@ -79,7 +88,11 @@ describe GildedRose do end it "quality should not be greater than 50" do - update_and_check_item(item_name: "Backstage passes to a TAFKAL80ETC concert", initial_sell_in: 10, initial_quant: 49, output: "Backstage passes to a TAFKAL80ETC concert, 9, 50") + update_and_check_item(item_name: "Backstage passes to a TAFKAL80ETC concert", initial_sell_in: 10, initial_quant: 50, output: "Backstage passes to a TAFKAL80ETC concert, 9, 50") + end + + it "when sell_in value is negative then quality should be zero" do + update_and_check_item(item_name: "Backstage passes to a TAFKAL80ETC concert", initial_sell_in: -1, initial_quant: 0, output: "Backstage passes to a TAFKAL80ETC concert, -2, 0") end context "Conjured Items" do @@ -92,7 +105,11 @@ describe GildedRose do end it "does not decrease quality below 0" do - update_and_check_item(item_name: "Conjured Mana Cake", initial_sell_in: 5, initial_quant: 1, output: "Conjured Mana Cake, 4, 0") + update_and_check_item(item_name: "Conjured Mana Cake", initial_sell_in: 5, initial_quant: 0, output: "Conjured Mana Cake, 4, 0") + end + + it "when sell_in value is negative" do + update_and_check_item(item_name: "Conjured Mana Cake", initial_sell_in: -1, initial_quant: 5, output: "Conjured Mana Cake, -2, 1") end end end diff --git a/ruby/texttest_fixture.rb b/ruby/texttest_fixture.rb index 98605f28..38902731 100644 --- a/ruby/texttest_fixture.rb +++ b/ruby/texttest_fixture.rb @@ -7,11 +7,14 @@ items = [ Item.new(name="+5 Dexterity Vest", sell_in=10, quality=20), Item.new(name="+5 Dexterity Vest", sell_in=0, quality=20), Item.new(name="+5 Dexterity Vest", sell_in=0, quality=0), + Item.new(name="+5 Dexterity Vest", sell_in=-1, quality=8), Item.new(name="Aged Brie", sell_in=2, quality=0), Item.new(name="Aged Brie", sell_in=0, quality=9), - Item.new(name="Aged Brie", sell_in=2, quality=49), + Item.new(name="Aged Brie", sell_in=2, quality=50), + Item.new(name="Aged Brie", sell_in=-1, quality=20), Item.new(name="Elixir of the Mongoose", sell_in=5, quality=7), Item.new(name="Sulfuras, Hand of Ragnaros", sell_in=0, quality=80), + Item.new(name="Sulfuras, Hand of Ragnaros", sell_in=0, quality=80), Item.new(name="Sulfuras, Hand of Ragnaros", sell_in=-1, quality=80), Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=15, quality=20), Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=10, quality=49), @@ -19,9 +22,11 @@ items = [ Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=10, quality=45), Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=5, quality=40), Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=0, quality=3), + Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=-1, quality=3), Item.new(name="Conjured Mana Cake", sell_in=3, quality=6), Item.new(name="Conjured Mana Cake", sell_in=0, quality=6), Item.new(name="Conjured Mana Cake", sell_in=5, quality=1), + Item.new(name="Conjured Mana Cake", sell_in=-1, quality=5) ] days = 2