Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarified kata requirements and fixed tests for conjured items. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Modified by me from the original, found at https://github.com/istepaniuk/gilded-rose-js-with-tests, in the following ways:

0. It's in Python 3 now. So, really the only original content is the README from "Coding Dojo" on
0. It's in Python 3 now. So, really the only original content is the README from "Coding Dojo" on [insert link, I propose this repo](https://github.com/emilybache/GildedRose-Refactoring-Kata)

## Installing

Expand Down Expand Up @@ -29,7 +29,7 @@ The final test, which relates to a new feature, is skipped. Remove the `@skip`
Coding Dojo
===========

Note that this Kata has been slightly modified from [the original](http://iamnotmyself.com/2011/02/13/refactor-this-the-gilded-rose-kata/) by Terry Hughes and Bobby Johnson. Namely, in the original Kata the Brie Cheese does not behave exactly like the Backstage passes as this code does. I also think the original kata has a bug on purpose so you have to fix it. This version was used in the Madrid Software Craftsmanship meetup group, and we wanted to focus on refactoring. We had limited time, so the tests are already written and green. [This is a post in my blog about that meeting.](http://blog.istepaniuk.com/refactoring-dojo-the-gilded-rose-kata)
Note that this Kata has been slightly modified from [the original, this link returns 404 now](http://iamnotmyself.com/2011/02/13/refactor-this-the-gilded-rose-kata/) by Terry Hughes and Bobby Johnson. Namely, in the original Kata the Brie Cheese does not behave exactly like the Backstage passes as this code does. I also think the original kata has a bug on purpose so you have to fix it. This version was used in the Madrid Software Craftsmanship meetup group, and we wanted to focus on refactoring. We had limited time, so the tests are already written and green. [This is a post in my blog about that meeting.](http://blog.istepaniuk.com/refactoring-dojo-the-gilded-rose-kata)

Gilded Rose
===========
Expand All @@ -49,12 +49,11 @@ Pretty simple, right? Well this is where it gets interesting:

- Once the sell by date has passed, Quality degrades twice as fast.
- The Quality of an item is never negative.
- "Aged Brie" increases in Quality the older it gets.
- The Quality of an item is never more than 50, but "Sulfuras" is a legendary item and as such its Quality is always 80 and it never alters.
- "Backstage passes", like "Aged Brie", increases by one in Quality as its SellIn date approaches
- Unlike normal items, both "Backstage passes" AND "Aged Brie" increase by one in Quality as their SellIn date approaches
- Quality increases by 2 when there are 10 days or less
- Quality increases by 3 when there are 5 days or less
- Quality drops to 0 after the concert
- Quality drops to 0 after the concert/it goes bad

We have recently signed a supplier of conjured items. This requires AN UPDATE to our system:

Expand Down
6 changes: 3 additions & 3 deletions gilded_rose_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ def test_quality_goes_up_by_three_for_improving_products_with_5_days_or_less_lef
self.assertEqual(item.quality, expectation['quality'])
self.assertEqual(item.sell_in, expectation['sell_in'])

def test_quality_and_sellin_decrease_twice_as_fast_after_sell_by(self):
def test_quality_decreases_twice_as_fast_after_sell_by(self):
self.items.append(Item("+5 Dexterity Vest", 0, 20))
self.items.append(Item("Conjured Mana Cake", 0, 6))
gilded_rose.update_quality(self.items)
expected = [
{'sell_in': -1, 'quality': 18},
{'sell_in': -1, 'quality': 4},
{'sell_in': -1, 'quality': 2},
]

for index, expectation in enumerate(expected):
Expand Down Expand Up @@ -109,7 +109,7 @@ def test_quality_does_not_increase_past_50(self):
def test_conjured_items_decrease_in_quality_twice_as_fast(self):
self.items.append(Item("Conjured Mana Cake", 3, 6))
gilded_rose.update_quality(self.items)
expected = {'sell_in': 2, 'quality': 2}
expected = {'sell_in': 2, 'quality': 4}
item = self.items[0]
self.assertEqual(item.quality, expected['quality'])
self.assertEqual(item.sell_in, expected['sell_in'])