diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/.PostRunner_spec.rb.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | test/FlexiTable_spec.rb | 14 | ||||
-rw-r--r-- | test/PostRunner_spec.rb | 69 |
3 files changed, 83 insertions, 0 deletions
diff --git a/test/.PostRunner_spec.rb.swp b/test/.PostRunner_spec.rb.swp Binary files differnew file mode 100644 index 0000000..db98879 --- /dev/null +++ b/test/.PostRunner_spec.rb.swp diff --git a/test/FlexiTable_spec.rb b/test/FlexiTable_spec.rb new file mode 100644 index 0000000..dedc9cb --- /dev/null +++ b/test/FlexiTable_spec.rb @@ -0,0 +1,14 @@ +require 'postrunner/FlexiTable' + +describe PostRunner::FlexiTable do + + it 'should create a simple ASCII table' do + t = PostRunner::FlexiTable.new do + row(%w( a bb )) + row(%w( ccc ddddd )) + end + puts t.to_s + end + +end + diff --git a/test/PostRunner_spec.rb b/test/PostRunner_spec.rb new file mode 100644 index 0000000..31e1510 --- /dev/null +++ b/test/PostRunner_spec.rb @@ -0,0 +1,69 @@ +require 'fileutils' + +require 'postrunner/Main' + +describe PostRunner::Main do + + def postrunner(args) + args = [ '--dbdir', @db_dir ] + args + old_stdout = $stdout + $stdout = (stdout = StringIO.new) + PostRunner::Main.new(args) + $stdout = old_stdout + stdout.string + end + + def create_fit_file(name, date) + a = Fit4Ruby::Activity.new + a.start_time = Time.parse(date) + a.duration = 30 * 60 + Fit4Ruby.write(name, a) + end + + before(:all) do + @db_dir = File.join(File.dirname(__FILE__), '.postrunner') + FileUtils.rm_rf(@db_dir) + FileUtils.rm_rf('FILE1.FIT') + create_fit_file('FILE1.FIT', '2014-07-01-8:00') + #create_fit_file('FILE2.FIT', '2014-07-02-8:00') + end + + after(:all) do + FileUtils.rm_rf(@db_dir) + FileUtils.rm_rf('FILE1.FIT') + end + + it 'should abort without arguments' do + lambda { postrunner([]) }.should raise_error SystemExit + end + + it 'should abort with bad command' do + lambda { postrunner(%w( foobar)) }.should raise_error SystemExit + end + + it 'should support the -v option' do + postrunner(%w( --version )) + end + + it 'should check a FIT file' do + postrunner(%w( check FILE1.FIT )) + end + + it 'should list and empty archive' do + postrunner(%w( list )) + end + + it 'should import a FIT file' do + postrunner(%w( import FILE1.FIT )) + end + + it 'should check the imported file' do + postrunner(%w( check :1 )) + end + + it 'should list the imported file' do + postrunner(%w( list )).index('FILE1.FIT').should be_a(Fixnum) + end + +end + |