From d44be018966cc153ff5501ff3fbd065f6c91b2ad Mon Sep 17 00:00:00 2001 From: mo k Date: Fri, 11 Nov 2011 20:08:51 -0700 Subject: start building library. --- library_specs.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 library_specs.rb 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 -- cgit v1.2.3