Permalink
Browse files

another project with broken tests; now fixed

  • Loading branch information...
talbright committed Nov 17, 2011
1 parent 1a1af4a commit 5d09a9355ff8847e880948345f5fbe8ee1262051
View
12 test/test_basic_parsing.rb 100644 → 100755
@@ -1,13 +1,11 @@
# encoding: UTF-8
-$: << '../lib'
-require 'test/unit'
-require 'ruby-hl7'
+require File.dirname(__FILE__) + '/test_helper'
class BasicParsing < Test::Unit::TestCase
def setup
- @simple_msh_txt = open( './test_data/test.hl7' ).readlines.first
- @empty_txt = open( './test_data/empty.hl7' ).readlines.first
- @empty_segments_txt = open( './test_data/empty_segments.hl7' ).readlines.first
+ @simple_msh_txt = TestHelper.load_hl7(:test).first
+ @empty_txt = TestHelper.load_hl7(:empty).first
+ @empty_segments_txt = TestHelper.load_hl7(:empty_segments).first
@base_msh = "MSH|^~\\&|LAB1||DESTINATION||19910127105114||ORU^R03|LAB1003929"
@base_msh_alt_delims = "MSH$@~\\&|LAB1||DESTINATION||19910127105114||ORU^R03|LAB1003929"
end
@@ -215,7 +213,7 @@ def test_segment_auto_set_id
end
def test_enumerable_parsing
- test_file = open( './test_data/test.hl7' )
+ test_file = TestHelper.load_hl7(:test,:string)
assert_not_nil( test_file )
msg = HL7::Message.new( test_file )
View
4 test/test_child_segment.rb 100644 → 100755
@@ -1,7 +1,5 @@
# encoding: UTF-8
-$: << '../lib'
-require 'test/unit'
-require 'ruby-hl7'
+require File.dirname(__FILE__) + '/test_helper'
class ChildSegment < Test::Unit::TestCase
def setup
View
4 test/test_default_segment.rb 100644 → 100755
@@ -1,7 +1,5 @@
# encoding: UTF-8
-$: << '../lib'
-require 'test/unit'
-require 'ruby-hl7'
+require File.dirname(__FILE__) + '/test_helper'
class MsaSegment < Test::Unit::TestCase
def setup
View
4 test/test_dynamic_segment_def.rb 100644 → 100755
@@ -1,7 +1,5 @@
# encoding: UTF-8
-$: << '../lib'
-require 'test/unit'
-require 'ruby-hl7'
+require File.dirname(__FILE__) + '/test_helper'
class DynamicSegmentDefinition < Test::Unit::TestCase
def setup
View
6 test/test_field_arrays.rb 100644 → 100755
@@ -1,10 +1,8 @@
-$: << '../lib'
-require 'test/unit'
-require '../lib/ruby-hl7'
+require File.dirname(__FILE__) + '/test_helper'
class BasicNameParsing < Test::Unit::TestCase
def setup
- @simple_msh_txt = open('../test_data/pid_name.hl7').readlines
+ @simple_msh_txt = TestHelper.load_hl7(:pid_name)
end
def test_read
View
@@ -0,0 +1,20 @@
+$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
+$LOAD_PATH.unshift(File.dirname(__FILE__))
+
+require 'test/unit'
+require 'ruby-hl7'
+
+
+module TestHelper
+ DATA_DIR = File.join(File.dirname(__FILE__), '..', 'test_data')
+
+ def self.load_hl7(name,kind=:array)
+ if(kind==:array)
+ File.open(File.join(DATA_DIR, "#{name.to_s}.hl7")).readlines
+ elsif(kind==:string)
+ File.open(File.join(DATA_DIR, "#{name.to_s}.hl7")) { |f| f.read }
+ else
+ File.open(File.join(DATA_DIR, "#{name.to_s}.hl7"))
+ end
+ end
+end
View
4 test/test_msa_segment.rb 100644 → 100755
@@ -1,7 +1,5 @@
# encoding: UTF-8
-$: << '../lib'
-require 'test/unit'
-require 'ruby-hl7'
+require File.dirname(__FILE__) + '/test_helper'
class MsaSegment < Test::Unit::TestCase
def setup
View
4 test/test_obr_segment.rb 100644 → 100755
@@ -1,7 +1,5 @@
# encoding: UTF-8
-$: << '../lib'
-require 'test/unit'
-require 'ruby-hl7'
+require File.dirname(__FILE__) + '/test_helper'
class ObrSegment < Test::Unit::TestCase
def setup
View
4 test/test_obx_segment.rb 100644 → 100755
@@ -1,7 +1,5 @@
# encoding: UTF-8
-$: << '../lib'
-require 'test/unit'
-require 'ruby-hl7'
+require File.dirname(__FILE__) + '/test_helper'
class ObxSegment < Test::Unit::TestCase
def setup
View
4 test/test_pid_segment.rb 100644 → 100755
@@ -1,7 +1,5 @@
# encoding: UTF-8
-$: << '../lib'
-require 'test/unit'
-require 'ruby-hl7'
+require File.dirname(__FILE__) + '/test_helper'
class PidSegment < Test::Unit::TestCase
def setup
View
4 test/test_speed_parsing.rb 100644 → 100755
@@ -1,8 +1,6 @@
# encoding: UTF-8
-$: << '../lib'
+require File.dirname(__FILE__) + '/test_helper'
require 'time'
-require 'test/unit'
-require 'ruby-hl7'
class SpeedParsing < Test::Unit::TestCase
def setup

0 comments on commit 5d09a93

Please sign in to comment.