mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 15:01:28 +00:00
Conjured cake now works. Check with client if need it to work for /Conjured .*/
This commit is contained in:
parent
31ba62bf31
commit
bcf614e2a0
@ -37,6 +37,15 @@ class GildedRose
|
||||
quality: self.regular_quality_limit(next_quality)
|
||||
}
|
||||
end,
|
||||
"Conjured Mana Cake" => Proc.new do |sell_in:, quality:|
|
||||
next_sell_in = sell_in -1
|
||||
{
|
||||
sell_in: next_sell_in,
|
||||
quality: self.regular_quality_limit(
|
||||
quality + (next_sell_in < 0 ? -4 : -2)
|
||||
)
|
||||
}
|
||||
end,
|
||||
}
|
||||
|
||||
def self.regular_quality_limit(unsanitized_quality)
|
||||
|
||||
@ -122,6 +122,30 @@ describe GildedRose do
|
||||
expect(items[0].sell_in).to eq 1 # does not change
|
||||
expect(items[0].quality).to eq 80 # always 80
|
||||
end
|
||||
|
||||
it "degrades conjured cake quickly" do
|
||||
items = [Item.new("Conjured Mana Cake", 2, 9)]
|
||||
updater = GildedRose.new(items)
|
||||
updater.update_quality()
|
||||
|
||||
expect(items[0].sell_in).to eq 1
|
||||
expect(items[0].quality).to eq 7 # degrades twice as fast
|
||||
|
||||
updater.update_quality()
|
||||
|
||||
expect(items[0].sell_in).to eq 0
|
||||
expect(items[0].quality).to eq 5 # still above zero
|
||||
|
||||
updater.update_quality()
|
||||
|
||||
expect(items[0].sell_in).to eq -1
|
||||
expect(items[0].quality).to eq 1 # still above zero
|
||||
|
||||
updater.update_quality()
|
||||
|
||||
expect(items[0].sell_in).to eq -2
|
||||
expect(items[0].quality).to eq 0 # does not go below zero
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user