mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +00:00
First pairing session
This commit is contained in:
parent
a0a860d0fe
commit
78080adc89
@ -3,11 +3,87 @@ require File.join(File.dirname(__FILE__), 'gilded_rose')
|
||||
describe GildedRose do
|
||||
|
||||
describe "#update_quality" do
|
||||
|
||||
it "does not change the name" do
|
||||
# Item#initialize(name, sell_in, quality)
|
||||
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
|
||||
|
||||
it "degrades twice as fast when sell by date has passed" do
|
||||
items = [Item.new("foo", 1, 20)]
|
||||
GildedRose.new(items).update_quality()
|
||||
expect(items[0].quality).to eq 19
|
||||
expect(items[0].sell_in).to eq 0 # One day has passed, quality degraded by one
|
||||
GildedRose.new(items).update_quality()
|
||||
expect(items[0].quality).to eq 17 # Sellin has passed, quality degrade by two
|
||||
end
|
||||
|
||||
it "never degrades quality to a negative number" do
|
||||
items = [Item.new("foo", 1, 1)]
|
||||
10.times { GildedRose.new(items).update_quality() }
|
||||
expect(items[0].sell_in).to eq -9
|
||||
expect(items[0].quality).to eq 0
|
||||
end
|
||||
|
||||
it "'Aged Brie' actually increases in Quality the older it gets" do
|
||||
items = [Item.new("Aged Brie", 20, 10)]
|
||||
GildedRose.new(items).update_quality()
|
||||
expect(items[0].quality).to eq 11
|
||||
10.times { GildedRose.new(items).update_quality() }
|
||||
expect(items[0].quality).to eq 21
|
||||
end
|
||||
|
||||
it "Quality of an item never goes above 50" do
|
||||
items = [Item.new("Aged Brie", 1, 49)]
|
||||
GildedRose.new(items).update_quality()
|
||||
expect(items[0].quality).to eq 50
|
||||
10.times { GildedRose.new(items).update_quality() }
|
||||
expect(items[0].quality).to eq 50
|
||||
end
|
||||
|
||||
it "'Sulfuras', being a legendary item, never has to be sold or decreases in Quality" do
|
||||
items = [Item.new("Sulfuras, Hand of Ragnaros", 1, 49)]
|
||||
item = items.first
|
||||
GildedRose.new(items).update_quality()
|
||||
expect(items[0].sell_in).to eq 1
|
||||
expect(items[0].quality).to eq 49
|
||||
end
|
||||
|
||||
it "'Backstage passes', like aged brie, increases in Quality as its SellIn value approaches" do
|
||||
items = [Item.new("Backstage passes to a TAFKAL80ETC concert", 20, 10)]
|
||||
GildedRose.new(items).update_quality()
|
||||
expect(items[0].quality).to eq 11
|
||||
end
|
||||
|
||||
it "'Backstage passes', quality increases by 2 when there are 10 days or less" do
|
||||
items = [Item.new("Backstage passes to a TAFKAL80ETC concert", 10, 11)]
|
||||
GildedRose.new(items).update_quality()
|
||||
expect(items[0].quality).to eq 13
|
||||
expect(items[0].sell_in).to eq 9
|
||||
4.times {GildedRose.new(items).update_quality()}
|
||||
expect(items[0].quality).to eq 21
|
||||
expect(items[0].sell_in).to eq 5
|
||||
end
|
||||
|
||||
it "'Backstage passes', quality increases by 3 when there are 5 days or less" do
|
||||
items = [Item.new("Backstage passes to a TAFKAL80ETC concert", 5, 30)]
|
||||
GildedRose.new(items).update_quality()
|
||||
expect(items[0].quality).to eq 33
|
||||
expect(items[0].sell_in).to eq 4
|
||||
end
|
||||
|
||||
it "'Backstage passes', quality drops to 0 after the concert" do
|
||||
items = [Item.new("Backstage passes to a TAFKAL80ETC concert", 1, 30)]
|
||||
GildedRose.new(items).update_quality()
|
||||
expect(items[0].quality).to eq 33
|
||||
expect(items[0].sell_in).to eq 0
|
||||
GildedRose.new(items).update_quality()
|
||||
expect(items[0].quality).to eq 0
|
||||
expect(items[0].sell_in).to eq -1
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -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
|
||||
25
ruby/prerefactor.txt
Normal file
25
ruby/prerefactor.txt
Normal file
@ -0,0 +1,25 @@
|
||||
OMGHAI!
|
||||
-------- day 0 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 10, 20
|
||||
Aged Brie, 2, 0
|
||||
Elixir of the Mongoose, 5, 7
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 15, 20
|
||||
Backstage passes to a TAFKAL80ETC concert, 10, 49
|
||||
Backstage passes to a TAFKAL80ETC concert, 5, 49
|
||||
Conjured Mana Cake, 3, 6
|
||||
|
||||
-------- day 1 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 9, 19
|
||||
Aged Brie, 1, 1
|
||||
Elixir of the Mongoose, 4, 6
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 14, 21
|
||||
Backstage passes to a TAFKAL80ETC concert, 9, 50
|
||||
Backstage passes to a TAFKAL80ETC concert, 4, 50
|
||||
Conjured Mana Cake, 2, 5
|
||||
|
||||
2401
ruby/prerefactor200day.txt
Normal file
2401
ruby/prerefactor200day.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -16,7 +16,7 @@ items = [
|
||||
Item.new(name="Conjured Mana Cake", sell_in=3, quality=6), # <-- :O
|
||||
]
|
||||
|
||||
days = 2
|
||||
days = 200
|
||||
if ARGV.size > 0
|
||||
days = ARGV[0].to_i + 1
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user