Skip to content

Commit

Permalink
test: corrige tests de items normales
Browse files Browse the repository at this point in the history
Usamos variables de instancia y no locales en before hook
  • Loading branch information
felgaete committed Aug 5, 2024
1 parent f8c4d82 commit 7918e7c
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions ruby/gilded_rose_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,44 @@
end

context 'para items normales' do
setup do
before do
## Arrange
items = [Item.new("foo", 10, 2)]
gilded = GildedRose.new(items)
@items = [Item.new("foo", 10, 2)]
@gilded = GildedRose.new(@items)
end


it 'decrementa la calidad del item' do
#Act
gilded.update_quality()
@gilded.update_quality()

#Assert
expect(items[0].quality).to eq 1
expect(@items[0].quality).to eq 1
end

it 'decrementa los dias para vender el item' do
#Act
gilded.update_quality()
@gilded.update_quality()

#Assert
expect(items[0].sell_in).to eq 9
expect(@items[0].sell_in).to eq 9
end

it 'decrementa la calidad del item al doble de velocidad cuando ya no quedan dias para venderlo' do
items[0].sell_in = 0
items[0].quality = 20
@items[0].sell_in = 0
@items[0].quality = 20

gilded.update_quality()
@gilded.update_quality()

expect(items[0].quality).to eq 18
expect(@items[0].quality).to eq 18
end

it 'no decrementa la calidad del item a negativo' do
items[0].quality = 0
@items[0].quality = 0

gilded.update_quality()
@gilded.update_quality()

expect(items[0].quality).to eq 0
expect(@items[0].quality).to eq 0
end
end

Expand Down

0 comments on commit 7918e7c

Please sign in to comment.