mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +00:00
corrected special_item method and added further test for this.
This commit is contained in:
parent
58be55719a
commit
89fb0d8689
@ -43,6 +43,7 @@ class GildedRose
|
||||
|
||||
if !item.name.downcase.match /backstage/
|
||||
update_normal_quality(item) unless sulfuras?(item)
|
||||
|
||||
else
|
||||
item.quality = 0
|
||||
end
|
||||
@ -67,7 +68,7 @@ class GildedRose
|
||||
end
|
||||
|
||||
def self.special_item?(item)
|
||||
!item.name.downcase.match( /Aged Brie/ || /backstage/) || !sulfuras?(item)
|
||||
item.name.downcase.match( /Aged Brie/ || /backstage/).nil? || sulfuras?(item)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -120,7 +120,7 @@ let(:sulfarus) { Item.new('Sulfuras, Hand of Ragnaros', 50, 80) }
|
||||
end
|
||||
|
||||
it 'returns true for backstage passes' do
|
||||
item_double = double :item, name: "backstage pass for gong party"
|
||||
item_double = double :item, name: "Backstage passes to a TAFKAL80ETC concert"
|
||||
expect(GildedRose.special_item?(item_double)).to eq true
|
||||
end
|
||||
|
||||
@ -128,6 +128,11 @@ let(:sulfarus) { Item.new('Sulfuras, Hand of Ragnaros', 50, 80) }
|
||||
sulfuras_double = double :selfarus, name: 'Sulfuras'
|
||||
expect(GildedRose.special_item?(sulfuras_double)).to eq true
|
||||
end
|
||||
|
||||
it 'returns false on potato' do
|
||||
item_double = double :item, name: "potato"
|
||||
expect(GildedRose.sulfuras?(item_double)).to eq false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user