From 2122d68f0408b8471f9dedd9998ecf890a90f703 Mon Sep 17 00:00:00 2001 From: Chris Jaekl Date: Fri, 12 Jul 2019 19:43:35 -0400 Subject: [PATCH] Rework store_test.rb using rspec --- Gemfile | 6 ++++++ Gemfile.lock | 30 ++++++++++++++++++++++++++++++ store.rb | 4 ++-- store_test.rb | 21 --------------------- test/store_test.rb | 24 ++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 23 deletions(-) create mode 100644 Gemfile create mode 100644 Gemfile.lock delete mode 100644 store_test.rb create mode 100644 test/store_test.rb diff --git a/Gemfile b/Gemfile new file mode 100644 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 index 0000000..6829438 --- /dev/null +++ b/Gemfile.lock @@ -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 diff --git a/store.rb b/store.rb index bf24b0e..92d1ce5 100644 --- 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 index 301be76..0000000 --- a/store_test.rb +++ /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 index 0000000..5ebeff1 --- /dev/null +++ b/test/store_test.rb @@ -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 -- 2.30.2