thetamind / gilded_rose_kata_elixir

GildedRose refactoring Kata solution in Elixir

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

GildedRose refactoring Kata solution in Elixir

License:MIT License


Languages

Language:Elixir 100.0%