mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +00:00
extracted #special_item? method and implemented in update quality section
This commit is contained in:
parent
7a8792f64f
commit
58be55719a
@ -38,13 +38,11 @@ class GildedRose
|
||||
|
||||
|
||||
if item.sell_in < 0
|
||||
|
||||
if item.name != "Aged Brie"
|
||||
|
||||
if !item.name.downcase.match /backstage/
|
||||
if item.quality > 0
|
||||
if !sulfuras?(item)
|
||||
update_normal_quality(item)
|
||||
end
|
||||
end
|
||||
update_normal_quality(item) unless sulfuras?(item)
|
||||
else
|
||||
item.quality = 0
|
||||
end
|
||||
@ -53,6 +51,9 @@ class GildedRose
|
||||
item.quality = item.quality + 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -64,6 +65,10 @@ class GildedRose
|
||||
def self.sulfuras?(item)
|
||||
!item.name.downcase.match( /sulfuras/).nil?
|
||||
end
|
||||
|
||||
def self.special_item?(item)
|
||||
!item.name.downcase.match( /Aged Brie/ || /backstage/) || !sulfuras?(item)
|
||||
end
|
||||
end
|
||||
|
||||
class Item
|
||||
|
||||
@ -112,6 +112,23 @@ let(:sulfarus) { Item.new('Sulfuras, Hand of Ragnaros', 50, 80) }
|
||||
expect(GildedRose.sulfuras?(item_double)).to eq false
|
||||
end
|
||||
end
|
||||
|
||||
describe '#special_item?' do
|
||||
it 'returns true for aged brie' do
|
||||
item_double = double :item, name: "Aged Brie"
|
||||
expect(GildedRose.special_item?(item_double)).to eq true
|
||||
end
|
||||
|
||||
it 'returns true for backstage passes' do
|
||||
item_double = double :item, name: "backstage pass for gong party"
|
||||
expect(GildedRose.special_item?(item_double)).to eq true
|
||||
end
|
||||
|
||||
it 'returns true for sulfuras' do
|
||||
sulfuras_double = double :selfarus, name: 'Sulfuras'
|
||||
expect(GildedRose.special_item?(sulfuras_double)).to eq true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user