From: Chris Jaekl Date: Fri, 12 Jul 2019 23:43:35 +0000 (-0400) Subject: Rework store_test.rb using rspec X-Git-Url: https://jaekl.net/gitweb/?a=commitdiff_plain;h=2122d68f0408b8471f9dedd9998ecf890a90f703;p=quanlib.git Rework store_test.rb using rspec --- 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