diff options
| author | mo k <m@mokhan.ca> | 2011-11-11 20:08:51 -0700 |
|---|---|---|
| committer | mo k <m@mokhan.ca> | 2011-11-11 20:08:51 -0700 |
| commit | d44be018966cc153ff5501ff3fbd065f6c91b2ad (patch) | |
| tree | 40c1ead15384619b258b2d1266afcc31b8078981 | |
| parent | 4a1602dac298f79195c7198fe360243b8375e857 (diff) | |
start building library.
| -rw-r--r-- | library_specs.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/library_specs.rb b/library_specs.rb new file mode 100644 index 0000000..9b54caf --- /dev/null +++ b/library_specs.rb @@ -0,0 +1,36 @@ +require "test/unit" +require_relative "book" + +# require "library" +class Library + def initialize + @books = [] + end + def add(book) + @books << book + end + def contains(title) + # puts @books.public_methods + found = @books.find do |book| + book.title == title + end + found != nil + # @books.any? + end +end + +class TestLibrary < Test::Unit::TestCase + def setup + @pickaxe = Book.new("The Ruby Programming Language") + @agile_web_development_with_rails = Book.new("Agile Web Development with Rails") + @library = Library.new + @library.add @pickaxe + @library.add @agile_web_development_with_rails + end + def test_should_tell_if_a_book_was_added + assert_equal(true, @library.contains(@pickaxe.title)) + end + def test_should_tell_when_a_book_was_not_added + assert_equal(false, @library.contains("little red riding hood")) + end +end |
