Skip to content

Latest commit

 

History

History
34 lines (20 loc) · 1.21 KB

README.md

File metadata and controls

34 lines (20 loc) · 1.21 KB

Gilded Rose Refactoring Kata

My implementation of the Gilded Rose Kata in Elixir.

How did I refactor a stream of conditionals nested nearly to infinity − 1?

Items are pattern matched on name in the function heads with guards on sell_in. This works well for special items; falling through to default behaviour for generic items.

def update_item(%Item{name: "Aged Brie", sell_in: sell_in} = item) when sell_in <= 0 do

Mutation of items are handled by composing single-purpose mutators.

item |> age() |> degrade(4)

Tests

Execute the tests:

$ elixir gilded_rose_test.exs

Unit tests were written based on the specification in the requirements document. They are not exhaustive. For example, the minimum quality limit is only checked for generic items.

There is one acceptance test matching the expected output provided for TextTest. Rather than attempt to install TextTest I wrote a simple driver that generates the report.