]> jaekl.net Git - quanlib.git/commitdiff
Add SeriesTest
authorChris Jaekl <chris@jaekl.net>
Sat, 22 Jun 2024 02:27:40 +0000 (22:27 -0400)
committerChris Jaekl <chris@jaekl.net>
Sat, 22 Jun 2024 02:27:40 +0000 (22:27 -0400)
app/series.rb
test/series_test.rb [new file with mode: 0644]

index 0621876fe6816fb65ccba9ac27cc5274687b158d..729f0db5ba91e503bc5c7e1ee658d48bbdf97465 100644 (file)
@@ -56,10 +56,10 @@ class Series
   def inspect
     data = []
     if nil != @age
-      data.push('age="' + @age.inspect + '"')
+      data.push('age=' + @age.inspect)
     end
     if nil != @code
-      data.push('code="' + @code.inspect + '"')
+      data.push('code=' + @code.inspect)
     end
     if nil != @descr
       data.push('descr="' + @descr + '"')
@@ -70,7 +70,7 @@ class Series
     if nil != @grouping
       data.push('grouping="' + @grouping + '"')
     end
-    return '(Series:' + data.join(',') + ')'
+    return '(Series: ' + data.join(' ') + ')'
   end
 
   def key
diff --git a/test/series_test.rb b/test/series_test.rb
new file mode 100644 (file)
index 0000000..e0810c6
--- /dev/null
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+require "test_helper"
+
+require "series"
+
+class SeriesTest < Minitest::Test
+  def test_inspect
+    age = "ya"
+    genre = "romance"
+    grouping = "LouisaAlcott"
+    code = "LW"
+    descr = "Little Women"
+    id = 1
+
+    series = Series.new(id)
+    series.age = age
+    series.genre = genre
+    series.grouping = grouping
+    series.code = code
+    series.descr = descr
+
+    expected = '(Series: age="ya" code="LW" descr="Little Women" genre="romance" grouping="LouisaAlcott")'
+
+    actual = series.inspect
+
+    assert_equal expected, actual
+  end
+end