Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jhsu/kata-21

Code Kata 21 from http://codekata.pragprog.com/2007/01/kata_twenty_one.html
https://github.com/jhsu/kata-21

Last synced: 2 days ago
JSON representation

Code Kata 21 from http://codekata.pragprog.com/2007/01/kata_twenty_one.html

Awesome Lists containing this project

README

        

# Code Kata 21

Attempted by Joseph Hsu

[![Build Status](https://secure.travis-ci.org/jhsu/kata-21.png)](http://travis-ci.org/jhsu/kata-21)

[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/jhsu/kata-21)

Kata from http://codekata.pragprog.com/2007/01/kata_twenty_one.html

list = List.new
assert_nil(list.find("fred"))
list.add("fred")
assert_equal("fred", list.find("fred").value())
assert_nil(list.find("wilma"))
list.add("wilma")
assert_equal("fred", list.find("fred").value())
assert_equal("wilma", list.find("wilma").value())
assert_equal(["fred", "wilma"], list.values())

list = List.new
list.add("fred")
list.add("wilma")
list.add("betty")
list.add("barney")
assert_equal(["fred", "wilma", "betty", "barney"], list.values())
list.delete(list.find("wilma"))
assert_equal(["fred", "betty", "barney"], list.values())
list.delete(list.find("barney"))
assert_equal(["fred", "betty"], list.values())
list.delete(list.find("fred"))
assert_equal(["betty"], list.values())
list.delete(list.find("betty"))
assert_equal([], list.values())

## Running tests

1. Install gems using `bundle install` (if on non-mac, run `bundle install --without=mac`)
2. run `rake`