Rework store_test.rb using rspec
authorChris Jaekl <chris@aphra.jaekl.net>
Fri, 12 Jul 2019 23:43:35 +0000 (19:43 -0400)
committerChris Jaekl <chris@aphra.jaekl.net>
Fri, 12 Jul 2019 23:43:35 +0000 (19:43 -0400)
Gemfile [new file with mode: 0644]
Gemfile.lock [new file with mode: 0644]
store.rb
store_test.rb [deleted file]
test/store_test.rb [new file with mode: 0644]

diff --git a/Gemfile b/Gemfile
new file mode 100644 (file)
index 0000000..4978fce
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,6 @@
+source 'https://rubygems.org'
+
+gem 'inifile'
+gem 'pg'
+gem 'rspec'
+gem 'tconn'
diff --git a/Gemfile.lock b/Gemfile.lock
new file mode 100644 (file)
index 0000000..6829438
--- /dev/null
@@ -0,0 +1,30 @@
+GEM
+  remote: https://rubygems.org/
+  specs:
+    diff-lcs (1.3)
+    inifile (3.0.0)
+    pg (1.1.4)
+    rspec (3.8.0)
+      rspec-core (~> 3.8.0)
+      rspec-expectations (~> 3.8.0)
+      rspec-mocks (~> 3.8.0)
+    rspec-core (3.8.2)
+      rspec-support (~> 3.8.0)
+    rspec-expectations (3.8.4)
+      diff-lcs (>= 1.2.0, < 2.0)
+      rspec-support (~> 3.8.0)
+    rspec-mocks (3.8.1)
+      diff-lcs (>= 1.2.0, < 2.0)
+      rspec-support (~> 3.8.0)
+    rspec-support (3.8.2)
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  inifile
+  pg
+  rspec
+
+BUNDLED WITH
+   2.0.2
index bf24b0e20c28a7fcbb9a373a656347811a16294b..92d1ce57d1917ea7309d86527fa96f5aa826581e 100644 (file)
--- a/store.rb
+++ b/store.rb
@@ -3,9 +3,9 @@ require 'csv'
 require 'fileutils'
 require 'inifile'
 require 'pg'
-require 'tconn'
+require_relative 'tconn'
 
-require 'series'
+require_relative 'series'
 
 class Store
   def unclassified_csv
diff --git a/store_test.rb b/store_test.rb
deleted file mode 100644 (file)
index 301be76..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-
-require 'minitest/autorun'
-require 'store'
-
-class StoreTest < MiniTest::Test
-  def test_construct_efs_path
-    data = [ [      1234, '00/00/00/12', '0000001234.dat'],
-             [         1, '00/00/00/00', '0000000001.dat'],
-            [1234567890, '12/34/56/78', '1234567890.dat'],
-            [   7778123, '00/07/77/81', '0007778123.dat'],
-            [      0x1b, '00/00/00/00', '0000000027.dat'] ]
-
-    store = Store.new()
-
-    for (input, expectedPath, expectedName) in data
-      (actualPath, actualName) = store.construct_efs_path(input)
-      assert_equal(expectedPath, actualPath)
-      assert_equal(expectedName, actualName)
-    end
-  end
-end
diff --git a/test/store_test.rb b/test/store_test.rb
new file mode 100644 (file)
index 0000000..5ebeff1
--- /dev/null
@@ -0,0 +1,24 @@
+
+require 'rspec/autorun'
+require_relative '../store'
+
+describe Store do
+  it "construct_efs_path produces paths and filenames as expected" do
+    data = [
+      [      1234, '00/00/00/12', '0000001234.dat'],
+      [         1, '00/00/00/00', '0000000001.dat'],
+      [1234567890, '12/34/56/78', '1234567890.dat'],
+      [   7778123, '00/07/77/81', '0007778123.dat'],
+      [      0x1b, '00/00/00/00', '0000000027.dat']
+    ]
+
+    store = Store.new('quanlib.ini')
+
+    data.each do |input, expectedPath, expectedName|
+      (actualPath, actualName) = store.construct_efs_path(input)
+
+      expect(actualPath).to eq(expectedPath)
+      expect(actualName).to eq(expectedName)
+    end
+  end
+end