test/isbn_spec.rb in isbn-2.0.7 vs test/isbn_spec.rb in isbn-2.0.8
- old
+ new
@@ -1,7 +1,7 @@
require "minitest/spec"
-require "isbn"
+require_relative "../lib/isbn"
MiniTest::Unit.autorun
describe ISBN do
ISBNS = [ ["0820472670","9780820472676"], ["0763740381","9780763740382"], ["0547168292","9780547168296"],
@@ -57,11 +57,20 @@
ISBN.valid?("9790879392788").must_equal true
ISBN.valid?("2900820472675").must_equal true
ISBN.valid?("012781910X").must_equal true
ISBN.valid?("9887401392").must_equal false
ISBN.valid?("082047267").must_equal false
+ ISBN.valid?(nil).must_equal false
end
it "should get isbn from source string" do
ISBN.from_string("ISBN:978-83-7659-303-6\nmore of content").must_equal "978-83-7659-303-6"
end
-end
\ No newline at end of file
+
+ it "should add dashes to isbn 13 without dashes" do
+ ISBN.with_dashes("9780763740382").must_equal "978-0-7637-4038-2"
+ end
+
+ it "should add dashes to isbn 10 without dashes" do
+ ISBN.with_dashes("0763740382").must_equal "0-7637-4038-2"
+ end
+end