From dbfc72c1c623b6acfb4b442c686ba362c2c206bc Mon Sep 17 00:00:00 2001 From: Prateep Kul <1.0@kul.asia> Date: Wed, 13 Oct 2021 11:25:11 -0500 Subject: [PATCH] Refactoring code and test --- .DS_Store | Bin 0 -> 6148 bytes ruby/gilded_rose.rb | 24 +++++------------------- ruby/gilded_rose_spec.rb | 4 ++-- ruby/gilded_rose_tests.rb | 4 ++-- 4 files changed, 9 insertions(+), 23 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..94930ee19cde919eea9fac08c9fa038d94b96bcf GIT binary patch literal 6148 zcmeHK!Ab)$5KY>uX+_+Fpx$!v)lqjc-^!qkb~I2ktF z=o)+HZrt;XeG!KJneBR)em8AdTPI-fDlDd zY+1YGakW;hmu0O|pOodezF#TJ!-J#Aq$sxcs>f&T`_be0Y4ZG{Y31+-D%mtRg;y|U zJA81WpdSWz;G4!z;|PfXVt^P}9tO+_DAt!}%d}HsfEf5819(12P(<5crcoUo(BSnE z#|wxkVB=c?Q5v)jW*T7xgzHp5oyyG%wXpu5e*gZTPof?%Kn(mV26&G*Ckf{3-( 0 - if item.name != "Sulfuras, Hand of Ragnaros" + inListOfThree = ["Aged Brie","Backstage passes to a TAFKAL80ETC concert","Sulfuras, Hand of Ragnaros"] + if not inListOfThree.include?(item.name) and item.quality > 0 item.quality = item.quality - 1 - end - end else if item.quality < 50 item.quality = item.quality + 1 if item.name == "Backstage passes to a TAFKAL80ETC concert" if item.sell_in < 11 - if item.quality < 50 item.quality = item.quality + 1 - end - end - if item.sell_in < 6 - if item.quality < 50 - item.quality = item.quality + 1 - end end end end @@ -35,13 +27,7 @@ class GildedRose if item.sell_in < 0 if item.name != "Aged Brie" if item.name != "Backstage passes to a TAFKAL80ETC concert" - if item.quality > 0 - if item.name != "Sulfuras, Hand of Ragnaros" - item.quality = item.quality - 1 - end - end - else - item.quality = item.quality - item.quality + item.quality = 0 end else if item.quality < 50 diff --git a/ruby/gilded_rose_spec.rb b/ruby/gilded_rose_spec.rb index 269fe1b0..e748d09d 100644 --- a/ruby/gilded_rose_spec.rb +++ b/ruby/gilded_rose_spec.rb @@ -1,12 +1,12 @@ require File.join(File.dirname(__FILE__), 'gilded_rose') +require 'pry' describe GildedRose do - describe "#update_quality" do it "does not change the name" do items = [Item.new("foo", 0, 0)] GildedRose.new(items).update_quality() - expect(items[0].name).to eq "fixme" + expect(items[0].name).to eq "foo" end end diff --git a/ruby/gilded_rose_tests.rb b/ruby/gilded_rose_tests.rb index 2e1b70d1..98c12418 100644 --- a/ruby/gilded_rose_tests.rb +++ b/ruby/gilded_rose_tests.rb @@ -6,7 +6,7 @@ class TestUntitled < Test::Unit::TestCase def test_foo items = [Item.new("foo", 0, 0)] GildedRose.new(items).update_quality() - assert_equal items[0].name, "fixme" + assert_equal items[0].name, "foo" end -end \ No newline at end of file +end