def author
@author
end
- def
def inspect
data = []
if nil != @ddc
- data.push('Dewey=' + @ddc.to_s)
+ data.push('Dewey=' + @ddc.to_s.inspect)
end
if nil != @lcc
- data.push('LCC=' + @lcc.to_s)
+ data.push('LCC=' + @lcc.to_s.inspect)
end
if nil != @author_grouping
- data.push('author_grouping=' + @author_grouping.to_s)
+ data.push('author_grouping=' + @author_grouping.to_s.inspect)
end
if nil != @author
- data.push('author=' + @author.to_s)
+ data.push('author=' + @author.to_s.inspect)
end
if nil != @title_grouping
- data.push('title_grouping=' + @title_grouping.to_s)
+ data.push('title_grouping=' + @title_grouping.to_s.inspect)
end
if nil != @title
- data.push('title=' + @title)
+ data.push('title=' + @title.inspect)
end
- return '(Classification:' + data.join(',') + ')'
+ return '(Classification: ' + data.join(', ') + ')'
end
def to_s
--- /dev/null
+# frozen_string_literal: true
+
+require "test_helper"
+require "classification"
+
+class ClassificationTest < Minitest::Test
+ def test_inspect
+ ddc = "973.3/092 B"
+ lcc = "E302.6.F7"
+ author_grouping = "BenjaminFranklin"
+ author_sort = "Franklin, Benjamin"
+ title_grouping = "Autobiography_of_Benjamin_Franklin"
+ title = "Autobiography of Benjamin Franklin"
+
+ classification = Classification.new(ddc, lcc, author_grouping, author_sort, title_grouping, title)
+
+ expected = '(Classification: Dewey="973.3/092 B", LCC="E302.6.F7", author_grouping="BenjaminFranklin", author="Franklin, Benjamin", title_grouping="Autobiography_of_Benjamin_Franklin", title="Autobiography of Benjamin Franklin")'
+ actual = classification.inspect
+
+ assert_equal expected, actual
+ end
+end