medivo 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/lib/medivo/version.rb +1 -1
  2. data/lib/pdf/medivo/fdf_generator.rb +29 -0
  3. data/lib/pdf/medivo/pdf_generator.rb +7 -2
  4. data/lib/pdf/medivo/pdf_group.rb +16 -0
  5. data/spec/dummy/log/development.log +458 -0
  6. data/spec/dummy/tmp/cache/assets/C46/F00/sprockets%2F2281d588b540056c5a7306c32a3761b9 +0 -0
  7. data/spec/dummy/tmp/cache/assets/C6C/8D0/sprockets%2F2f423a28516973330a94ad121151f3bf +0 -0
  8. data/spec/dummy/tmp/cache/assets/C81/D00/sprockets%2F64f056bd752d271308a86a6f865b1911 +0 -0
  9. data/spec/dummy/tmp/cache/assets/CB4/BD0/sprockets%2F3378f27c0d4f5e6d708665b22707a31f +0 -0
  10. data/spec/dummy/tmp/cache/assets/CC3/EF0/sprockets%2F453b504c1f8f374578636f699eaa455d +0 -0
  11. data/spec/dummy/tmp/cache/assets/CD8/DA0/sprockets%2F622aa5281d15503829a5f7a0bf56fc29 +0 -0
  12. data/spec/dummy/tmp/cache/assets/CDD/820/sprockets%2Fb28231960c7ac62eff9048e702a29c70 +0 -0
  13. data/spec/dummy/tmp/cache/assets/CEC/EF0/sprockets%2F4b24a74018f693c06088bd52f8cc9f86 +0 -0
  14. data/spec/dummy/tmp/cache/assets/CEE/250/sprockets%2F96688f33f2f8aa261bf6701c1d6d7575 +0 -0
  15. data/spec/dummy/tmp/cache/assets/D07/6B0/sprockets%2F69a2df619ff14da071309dac4196400e +0 -0
  16. data/spec/dummy/tmp/cache/assets/D1B/820/sprockets%2F92a83e15913997b3d9ac7ed437b1e44c +0 -0
  17. data/spec/dummy/tmp/cache/assets/D20/F10/sprockets%2Fb2e907e4faa85fe755f4439e3b229088 +0 -0
  18. data/spec/dummy/tmp/cache/assets/D29/000/sprockets%2F61a10ddf57f1129c02a1049bfed6e007 +0 -0
  19. data/spec/dummy/tmp/cache/assets/D2C/F80/sprockets%2F399f6d5eb273936af7ff8f35a77c5037 +0 -0
  20. data/spec/dummy/tmp/cache/assets/D30/920/sprockets%2Fcc4603fc6441ca421a7d02886a81ab9d +0 -0
  21. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  22. data/spec/dummy/tmp/cache/assets/D36/870/sprockets%2Fce9e887568de873b133ae43d7c977f68 +0 -0
  23. data/spec/dummy/tmp/cache/assets/D41/250/sprockets%2F7b3c4426715dcd1feedc4a95e5444256 +0 -0
  24. data/spec/dummy/tmp/cache/assets/D45/320/sprockets%2Fc50ff379a1bdf1dd4d22249058749cf6 +0 -0
  25. data/spec/dummy/tmp/cache/assets/D4C/7A0/sprockets%2Fbc635c7b186d1ef5178f4ed3722d868b +0 -0
  26. data/spec/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +0 -0
  27. data/spec/dummy/tmp/cache/assets/D55/ED0/sprockets%2F0f673e42e816c6fe5b66a5c96f896f1a +0 -0
  28. data/spec/dummy/tmp/cache/assets/D5D/3E0/sprockets%2F63fea6cc142b5f02da93bf81e70b2116 +0 -0
  29. data/spec/dummy/tmp/cache/assets/D60/030/sprockets%2Ffc9485f617fc5e9b8918755d2e08ecc6 +0 -0
  30. data/spec/dummy/tmp/cache/assets/D64/C50/sprockets%2F22ee6fb2ab1ea9694ac7f0f41a406094 +0 -0
  31. data/spec/dummy/tmp/cache/assets/D65/6D0/sprockets%2F3ce07ca1958d7ab3e80c4b3e0d24088c +0 -0
  32. data/spec/dummy/tmp/cache/assets/D69/130/sprockets%2Fbaa4ec50a34ce938c986612c2a47a64e +0 -0
  33. data/spec/dummy/tmp/cache/assets/D74/9A0/sprockets%2F0ca4e6e833c72156fc7e7d5f007d9ce3 +0 -0
  34. data/spec/dummy/tmp/cache/assets/D76/720/sprockets%2F88d8aa1d2fb41ce79b8ec4150ea74748 +0 -0
  35. data/spec/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +0 -0
  36. data/spec/dummy/tmp/cache/assets/D88/2C0/sprockets%2F452ab3ebb1912cf1c2ba617eec52a718 +0 -0
  37. data/spec/dummy/tmp/cache/assets/D9C/F50/sprockets%2F224e78bb9e1c414a2d518a3aaffd6f77 +0 -0
  38. data/spec/dummy/tmp/cache/assets/D9F/260/sprockets%2Fa3e040f83c30e4bbc1c79ffae57909e6 +0 -0
  39. data/spec/dummy/tmp/cache/assets/DA1/640/sprockets%2F91874cbba5e63cd19d6a7bd3c8362dc4 +0 -0
  40. data/spec/dummy/tmp/cache/assets/DC1/230/sprockets%2F3a36cd467bdce1914a2b7af4ed4114cf +0 -0
  41. data/spec/dummy/tmp/cache/assets/DCE/E80/sprockets%2Fc71ec62157b9cc7aabfc030955cef87b +0 -0
  42. data/spec/dummy/tmp/cache/assets/DD1/FD0/sprockets%2Fa531f33dc9c5852d39d64a9eda44dacf +0 -0
  43. data/spec/dummy/tmp/cache/assets/DD4/2B0/sprockets%2Fef214a63f29afe7f3cbffc65af943108 +0 -0
  44. data/spec/dummy/tmp/cache/assets/DFC/420/sprockets%2F502e2c683d1aaad6ac88966ffc4d2ade +0 -0
  45. data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  46. data/spec/dummy/tmp/cache/assets/E32/FC0/sprockets%2Fe55fb2eef11567fe04fdaf7e73af5ba4 +0 -0
  47. data/spec/fixtures/uhc_requisition_cover_letter.pdf +0 -0
  48. data/spec/lib/fdf_generator_spec.rb +2 -1
  49. data/spec/lib/pdf_generator_spec.rb +32 -17
  50. data/spec/lib/pdf_group_spec.rb +17 -19
  51. data/spec/models/orders_spec.rb +29 -14
  52. data/spec/spec_helper.rb +3 -0
  53. data/spec/support/blueprints.rb +60 -57
  54. data/spec/support/helper.rb +37 -10
  55. metadata +19 -19
@@ -12,7 +12,8 @@ describe Medivo::FdfGenerator do
12
12
  end
13
13
 
14
14
  it "fill in pdf form" do
15
- pdf_output = `pdftk "#{ENGINE_PATH}/spec/fixtures/negative_results.pdf" fill_form #{@fdf.path} output - flatten`
15
+ pdf_path = fixture_path "negative_results.pdf"
16
+ pdf_output = `pdftk #{pdf_path} fill_form #{@fdf.path} output - flatten`
16
17
  text = pdf_stream_to_text(pdf_output)
17
18
  text.should =~ /jane/
18
19
  text.should =~ Regexp.new(@birth_date)
@@ -3,21 +3,36 @@ require 'spec_helper'
3
3
  describe Medivo::PdfGenerator do
4
4
 
5
5
  it "#variable_fields generates pdf by filling in the variables" do
6
- #name = "Duderoni"
7
- name = <<-MD
8
- Catherine E. Palmier, M.D.
9
- Chief Medical Officer,
10
- UnitedHealthcare Clinical Services
11
- Southeast Region
12
- MD
13
- path = "#{ENGINE_PATH}/spec/fixtures/uhc_requisition_cover_letter.pdf"
14
- #path = "#{ENGINE_PATH}/spec/fixtures/negative_results.pdf"
15
- pdf_file = Medivo::PdfGenerator.variable_fields(path, {'director_name'=>name})
16
- #pdf_file = Medivo::PdfGenerator.variable_fields(path, {:patient_name=>name})
6
+ name = "Duderoni"
7
+ path = fixture_path "negative_results.pdf"
8
+ pdf_file = Medivo::PdfGenerator.variable_fields(path, {:patient_name=>name})
17
9
  text = pdf_to_text(pdf_file)
18
10
  text.should match name
19
11
  end
20
12
 
13
+ it "#variable_fields generates pdf by filling in the variables" do
14
+
15
+ fields = {
16
+ :full_name => 'my full name',
17
+ :address => 'my address',
18
+ :first_name => 'me!!!!!',
19
+ :sched_date => 'todays date',
20
+ :app_date => 'my appt date',
21
+ :app_time => 'my appt time',
22
+ :lab_name => 'LabCorp',
23
+ :lab_address => 'the lab address',
24
+ :order_number => 'the lab id'
25
+ }
26
+
27
+ path = fixture_path "uhc_requisition_cover_letter.pdf"
28
+ pdf_file = Medivo::PdfGenerator.variable_fields(path, fields)
29
+ text = pdf_to_text(pdf_file)
30
+ fields.values.each do |value|
31
+ text.should match value
32
+ end
33
+ end
34
+
35
+
21
36
  it "#variable_fields accepts image param and stamps image onto pdf" do
22
37
  md = <<-MD
23
38
  Catherine E. Palmier, M.D.
@@ -26,12 +41,12 @@ MD
26
41
  Southeast Region
27
42
  MD
28
43
 
29
- path = "#{ENGINE_PATH}/spec/fixtures/uhc_requisition_cover_letter.pdf"
30
- img_path = "#{ENGINE_PATH}/spec/fixtures/Southeast.jpg"
31
- pdf_file = Medivo::PdfGenerator.variable_fields(path, {'director_name'=>md})
32
- #pdf_file = Medivo::PdfGenerator.variable_fields_with_images(path, {:director_name=>md}, [{:path=> img_path, :at=> [0, 120]}])
33
- #open('/tmp/test.pdf', 'wb+') { |f| f.write pdf.read }
44
+ path = fixture_path "uhc_requisition_cover_letter.pdf"
45
+ img_path = fixture_path "Southeast.jpg"
46
+ pdf_file = Medivo::PdfGenerator.variable_fields_with_images(path, {:director_name=>md}, [{:path=> img_path, :at=> [0, 120]}])
47
+ #open('/tmp/test.pdf', 'wb+') { |f| f.write pdf_file.read }
34
48
  text = pdf_to_text(pdf_file)
35
- text.should match md
49
+ text.should match "Catherine E. Palmier, M.D."
50
+ pdf_file.unlink
36
51
  end
37
52
  end
@@ -4,34 +4,33 @@ describe Medivo::PdfGroup do
4
4
 
5
5
  it "#variable_fields" do
6
6
  name = "Duderoni"
7
- path = "#{ENGINE_PATH}/spec/fixtures/negative_results.pdf"
7
+ o = OpenStruct.new(:name=>name)
8
+ path = fixture_path "negative_results.pdf"
8
9
  pdf = Medivo::PdfGroup.create do
9
- variable_fields(path, {:patient_name=>name})
10
+ variable_fields(path, {:patient_name=>o.name})
10
11
  end
11
12
  text = pdf_to_text(pdf)
12
13
  text.should match name
13
14
  end
14
15
 
15
16
  it "#lab_requisition" do
16
- requisition_number = 170420
17
- stub_request(:get, "test:test@test.medivo.com/customers/#{requisition_number}.xml?include=requisition").
18
- to_return(:body => File.read("#{ENGINE_PATH}/spec/fixtures/lc_order_with_requisition.xml"))
17
+ requisition_id = 170420
18
+ stub_order_requisition(requisition_id, "lc_order_with_requisition.xml")
19
19
 
20
20
  pdf = Medivo::PdfGroup.create do
21
- lab_requisition(requisition_number)
21
+ lab_requisition(requisition_id)
22
22
  end
23
23
 
24
24
  text = pdf_to_text(pdf)
25
- text.should match "Account #:111111111 Req\/Control #:#{requisition_number}"
25
+ text.should match "Account #:111111111 Req\/Control #:#{requisition_id}"
26
26
  end
27
27
 
28
28
  it "#lab_result" do
29
- requisition_number = 170420
30
- stub_request(:get, "test:test@test.medivo.com/customers/#{requisition_number}.xml?include=reconciled_results").
31
- to_return(:body => File.read(("#{ENGINE_PATH}/spec/fixtures/lc_order_with_positive_results.xml")))
29
+ requisition_id = 170420
30
+ stub_order_result(requisition_id, "lc_order_with_positive_results.xml")
32
31
 
33
32
  pdf = Medivo::PdfGroup.create do
34
- lab_result(requisition_number)
33
+ lab_result(requisition_id)
35
34
  end
36
35
 
37
36
  text = pdf_to_text(pdf)
@@ -39,7 +38,7 @@ describe Medivo::PdfGroup do
39
38
  end
40
39
 
41
40
  it "#static_pdf" do
42
- path = "#{ENGINE_PATH}/spec/fixtures/result_faq.pdf"
41
+ path = fixture_path "result_faq.pdf"
43
42
  pdf = Medivo::PdfGroup.create do
44
43
  static_pdf(path)
45
44
  end
@@ -50,23 +49,22 @@ describe Medivo::PdfGroup do
50
49
 
51
50
  it "handles a combination of pdfs" do
52
51
  name = "Duderoni"
53
- cover_letter_path = "#{ENGINE_PATH}/spec/fixtures/negative_results.pdf"
52
+ cover_letter_path = fixture_path "negative_results.pdf"
54
53
 
55
- requisition_number = 170420
56
- stub_request(:get, "test:test@test.medivo.com/customers/#{requisition_number}.xml?include=requisition").
57
- to_return(:body => File.read("#{ENGINE_PATH}/spec/fixtures/lc_order_with_requisition.xml"))
54
+ requisition_id = 170420
55
+ stub_order_requisition(requisition_id, "lc_order_with_requisition.xml")
58
56
 
59
- faq_path = "#{ENGINE_PATH}/spec/fixtures/result_faq.pdf"
57
+ faq_path = fixture_path "result_faq.pdf"
60
58
 
61
59
  pdf = Medivo::PdfGroup.create do
62
60
  variable_fields(cover_letter_path, {:patient_name=>name})
63
- lab_requisition(requisition_number)
61
+ lab_requisition(requisition_id)
64
62
  static_pdf(faq_path)
65
63
  end
66
64
  # open('/tmp/test.pdf', 'wb+') { |f| f.write pdf.read }
67
65
  text = pdf_to_text(pdf)
68
66
  text.should match name
69
- text.should match "Account #:111111111 Req\/Control #:#{requisition_number}"
67
+ text.should match "Account #:111111111 Req\/Control #:#{requisition_id}"
70
68
  text.should match "Q: What does a positive result mean"
71
69
  end
72
70
  end
@@ -1,5 +1,22 @@
1
1
  require 'spec_helper'
2
2
 
3
+ module Medivo::Spec
4
+ def pdf_to_text(file)
5
+ pdf = PDF::Toolkit.open(file)
6
+ pdf.to_text.read.force_encoding('ascii-8bit')
7
+ end
8
+
9
+ def pdf_stream_to_text(bytes)
10
+ pdf = Tempfile.new('pdf', :encoding => 'ascii-8bit')
11
+ pdf.write bytes
12
+ pdf.close
13
+ text = pdf_to_text pdf
14
+ pdf.unlink
15
+ text
16
+ end
17
+ end
18
+
19
+
3
20
  describe Medivo::Order do
4
21
 
5
22
  it "requires fields to be present" do
@@ -119,12 +136,12 @@ describe Medivo::Order do
119
136
  describe "getting requisitions with" do
120
137
 
121
138
  before(:each) do
122
- @reqiuisition_number = 170420
123
- order = Medivo::Order.new(:requisition_number=> @reqiuisition_number)
124
- stub_request(:get, "test:test@test.medivo.com/customers/#{order.requisition_id}.xml?include=requisition").
125
- to_return(:body => File.read("#{ENGINE_PATH}/spec/fixtures/lc_order_with_requisition.xml"))
139
+ @requisition_id = 170420
140
+ order = Medivo::Order.new(:requisition_number=> @requisition_id)
141
+ stub_order_requisition(@requisition_id, "lc_order_with_requisition.xml")
126
142
  end
127
- let(:order) { Medivo::Order.find_with_requisition(@reqiuisition_number) }
143
+
144
+ let(:order) { Medivo::Order.find_with_requisition(@requisition_id) }
128
145
 
129
146
  it "#find_with_requisition finds the order including the requisition info" do
130
147
  order.should_not be_nil
@@ -140,7 +157,7 @@ describe Medivo::Order do
140
157
  end
141
158
 
142
159
  it "class method #pdf_requisition returns pdf requisition" do
143
- pdf = Medivo::Order.pdf_requisition(@reqiuisition_number)
160
+ pdf = Medivo::Order.pdf_requisition(@requisition_id)
144
161
  text = pdf_stream_to_text(pdf)
145
162
  text.should match /This order expires 2012-02-12/
146
163
  text.should match /Account #:111111111 Req\/Control #:170420/
@@ -151,14 +168,12 @@ describe Medivo::Order do
151
168
  describe "getting results with" do
152
169
 
153
170
  before(:each) do
154
- @reqiuisition_number = 170853
155
- order = Medivo::Order.new(:requisition_number=>@reqiuisition_number)
156
- stub_request(:get, "test:test@test.medivo.com/customers/#{order.requisition_id}.xml?include=reconciled_results").
157
- to_return(:body => File.read(("#{ENGINE_PATH}/spec/fixtures/lc_order_with_positive_results.xml")))
158
-
171
+ @requisition_id = 170853
172
+ order = Medivo::Order.new(:requisition_number=>@requisition_id)
173
+ stub_order_result(@requisition_id, "lc_order_with_positive_results.xml")
159
174
  end
160
175
 
161
- let(:order) { Medivo::Order.find_with_results(@reqiuisition_number) }
176
+ let(:order) { Medivo::Order.find_with_results(@requisition_id) }
162
177
 
163
178
  it "#find_with_results finds the order including results info" do
164
179
  order.should_not be_nil
@@ -180,7 +195,7 @@ describe Medivo::Order do
180
195
  end
181
196
 
182
197
  it "class method #pdf_result returns has results as pdf" do
183
- pdf = Medivo::Order.pdf_result(@reqiuisition_number)
198
+ pdf = Medivo::Order.pdf_result(@requisition_id)
184
199
  text = pdf_stream_to_text(pdf)
185
200
  text.should match /COLLECTED:2011-09-06 RECEIVED:2011-09-06 REPORTED:2011-09-06/
186
201
  end
@@ -233,7 +248,7 @@ describe "creating orders" do
233
248
 
234
249
 
235
250
  mock.proxy(order).to_xml({}) do |value|
236
- value.gsub(/\s/, '').should == File.read("#{ENGINE_PATH}/spec/fixtures/valid_uhc_order.xml").gsub(/\s/, '')
251
+ value.strip_space.should == File.read("#{ENGINE_PATH}/spec/fixtures/valid_uhc_order.xml").strip_space
237
252
  value
238
253
  end
239
254
 
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'spork'
2
+
1
3
  Spork.prefork do
2
4
 
3
5
  ENV["RAILS_ENV"] = "test"
@@ -19,6 +21,7 @@ Spork.prefork do
19
21
  config.mock_with :rr
20
22
  #config.use_transactional_fixtures = true
21
23
  config.include Medivo::Engine.routes.url_helpers
24
+ config.include Medivo::Spec
22
25
  config.before(:each) { Machinist.reset_before_test }
23
26
  end
24
27
 
@@ -1,61 +1,64 @@
1
+ unless defined? BeverlyHillsLab1
1
2
 
2
- BeverlyHillsLab1 = Medivo::Lab.new(
3
- "id"=>1752,
4
- "lab_id"=> 129,
5
- "name"=>"LABCORP, BEVERLY HILLS, 465 N ROXBURY DR STE 715",
6
- "active"=>true,
7
- "address"=>"465 N ROXBURY DR STE 715",
8
- "city"=>"BEVERLY HILLS",
9
- "code"=>"20060",
10
- "distance"=>"1.4191127132891",
11
- "hours"=>"MONDAY-FRIDAY LUNCH SATURDAY, 8:00AM-5:00PM NOON-1:00PM 9:00AM-1:00PM",
12
- "lat"=>"34.06831",
13
- "lng"=>"-118.40716",
14
- "long"=>"-118.40716",
15
- "state"=>"CA",
16
- "telephone"=>"310-275-4953",
17
- "type_of_service"=>"Routine Clinical Laboratory Collections, Pediatric",
18
- "updated_at"=>"2011-01-25T09:51:11Z",
19
- "zip"=>"90210"
20
- )
3
+ BeverlyHillsLab1 = Medivo::Lab.new(
4
+ "id"=>1752,
5
+ "lab_id"=> 129,
6
+ "name"=>"LABCORP, BEVERLY HILLS, 465 N ROXBURY DR STE 715",
7
+ "active"=>true,
8
+ "address"=>"465 N ROXBURY DR STE 715",
9
+ "city"=>"BEVERLY HILLS",
10
+ "code"=>"20060",
11
+ "distance"=>"1.4191127132891",
12
+ "hours"=>"MONDAY-FRIDAY LUNCH SATURDAY, 8:00AM-5:00PM NOON-1:00PM 9:00AM-1:00PM",
13
+ "lat"=>"34.06831",
14
+ "lng"=>"-118.40716",
15
+ "long"=>"-118.40716",
16
+ "state"=>"CA",
17
+ "telephone"=>"310-275-4953",
18
+ "type_of_service"=>"Routine Clinical Laboratory Collections, Pediatric",
19
+ "updated_at"=>"2011-01-25T09:51:11Z",
20
+ "zip"=>"90210"
21
+ )
21
22
 
22
- BeverlyHillsLab2 = Medivo::Lab.new(
23
- "id"=>1753,
24
- "lab_id"=>129,
25
- "name"=>"LABCORP, LOS ANGELES, 8737 BEVERLY BLVD STE 401",
26
- "active"=>true,
27
- "address"=>"8737 BEVERLY BLVD STE 401",
28
- "city"=>"LOS ANGELES",
29
- "code"=>"22974",
30
- "distance"=>"1.6266877775802",
31
- "fax"=>"310-652-0676",
32
- "hours"=>"MONDAY-FRIDAY LUNCH, 8:00AM-5:00PM NOON-1:00PM",
33
- "lat"=>"34.076852",
34
- "lng"=>"-118.381669",
35
- "long"=>"-118.381669",
36
- "state"=>"CA",
37
- "telephone"=>"310-652-0542",
38
- "type_of_service"=>"Routine Clinical Laboratory Collections, Pediatric",
39
- "updated_at"=>"2011-01-25T09:51:17Z",
40
- "zip"=>"90048"
41
- )
23
+ BeverlyHillsLab2 = Medivo::Lab.new(
24
+ "id"=>1753,
25
+ "lab_id"=>129,
26
+ "name"=>"LABCORP, LOS ANGELES, 8737 BEVERLY BLVD STE 401",
27
+ "active"=>true,
28
+ "address"=>"8737 BEVERLY BLVD STE 401",
29
+ "city"=>"LOS ANGELES",
30
+ "code"=>"22974",
31
+ "distance"=>"1.6266877775802",
32
+ "fax"=>"310-652-0676",
33
+ "hours"=>"MONDAY-FRIDAY LUNCH, 8:00AM-5:00PM NOON-1:00PM",
34
+ "lat"=>"34.076852",
35
+ "lng"=>"-118.381669",
36
+ "long"=>"-118.381669",
37
+ "state"=>"CA",
38
+ "telephone"=>"310-652-0542",
39
+ "type_of_service"=>"Routine Clinical Laboratory Collections, Pediatric",
40
+ "updated_at"=>"2011-01-25T09:51:17Z",
41
+ "zip"=>"90048"
42
+ )
42
43
 
43
- ValidPrimaryInsuranceSample = Medivo::PrimaryInsurance.new(
44
- :relationship=>1,
45
- :company_name=>"Dude Insurance",
46
- :policy_number=>"1234",
47
- :group_number =>"555"
48
- )
44
+ ValidPrimaryInsuranceSample = Medivo::PrimaryInsurance.new(
45
+ :relationship=>1,
46
+ :company_name=>"Dude Insurance",
47
+ :policy_number=>"1234",
48
+ :group_number =>"555"
49
+ )
49
50
 
50
- Order1 = Medivo::Order.new(
51
- :email => "dude@dude.com",
52
- :address=> "my house",
53
- :zip=> "10005",
54
- :dob=> "19801201",
55
- :home_phone=> "4155551212",
56
- :psc=> 11,
57
- :test_types=> [144028],
58
- :account_number => "423",
59
- :gender => "Male",
60
- :dob => "19801201"
61
- )
51
+ Order1 = Medivo::Order.new(
52
+ :email => "dude@dude.com",
53
+ :address=> "my house",
54
+ :zip=> "10005",
55
+ :dob=> "19801201",
56
+ :home_phone=> "4155551212",
57
+ :psc=> 11,
58
+ :test_types=> [144028],
59
+ :account_number => "423",
60
+ :gender => "Male",
61
+ :dob => "19801201"
62
+ )
63
+
64
+ end
@@ -4,14 +4,41 @@ class String
4
4
  end
5
5
  end
6
6
 
7
- def pdf_to_text(file)
8
- pdf = PDF::Toolkit.open(file)
9
- pdf.to_text.read.force_encoding('ascii-8bit')
10
- end
7
+ module Medivo::Spec
8
+ def pdf_to_text(file)
9
+ pdf = PDF::Toolkit.open(file)
10
+ pdf.to_text.read.force_encoding('ascii-8bit')
11
+ end
11
12
 
12
- def pdf_stream_to_text(bytes)
13
- pdf = Tempfile.new('pdf', :encoding => 'ascii-8bit')
14
- pdf.write bytes
15
- pdf.close
16
- pdf_to_text pdf
17
- end
13
+ def pdf_stream_to_text(bytes)
14
+ pdf = Tempfile.new('pdf', :encoding => 'ascii-8bit')
15
+ pdf.write bytes
16
+ pdf.close
17
+ pdf_to_text pdf
18
+ pdf.unlink
19
+ end
20
+
21
+ FIXTURE_PATH = File.expand_path('../../fixtures', __FILE__) unless defined? FIXTURE_PATH
22
+
23
+ def fixture_path(file_name)
24
+ "#{FIXTURE_PATH}/#{file_name}"
25
+ end
26
+
27
+ ##
28
+ # requisition_id Number id of the Medivo::Order you are stubbing
29
+ # file_path String points to the path to xml file with order info which contains
30
+ # requisition that includes requisition pdf
31
+ def stub_order_requisition(requisition_id, file_path)
32
+ stub_request(:get, "test:test@test.medivo.com/customers/#{requisition_id}.xml?include=requisition").
33
+ to_return(:body => File.read(fixture_path(file_path)))
34
+ end
35
+
36
+ ##
37
+ # requisition_id Number id of the Medivo::Order you are stubbing
38
+ # file_path String points to the path to xml file with order info which contains
39
+ # result info that includes result pdf
40
+ def stub_order_result(requisition_id, file_path)
41
+ stub_request(:get, "test:test@test.medivo.com/customers/#{requisition_id}.xml?include=reconciled_results").
42
+ to_return(:body => File.read(fixture_path(file_path)))
43
+ end
44
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: medivo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &2165402620 !ruby/object:Gem::Requirement
17
+ requirement: &2152646500 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 3.1.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2165402620
25
+ version_requirements: *2152646500
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: jquery-rails
28
- requirement: &2165402180 !ruby/object:Gem::Requirement
28
+ requirement: &2152646080 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2165402180
36
+ version_requirements: *2152646080
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: coffee-script
39
- requirement: &2165401640 !ruby/object:Gem::Requirement
39
+ requirement: &2152645540 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *2165401640
47
+ version_requirements: *2152645540
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: haml-rails
50
- requirement: &2165401220 !ruby/object:Gem::Requirement
50
+ requirement: &2152645100 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *2165401220
58
+ version_requirements: *2152645100
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: geocoder
61
- requirement: &2165400800 !ruby/object:Gem::Requirement
61
+ requirement: &2152644680 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0'
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *2165400800
69
+ version_requirements: *2152644680
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rest-client
72
- requirement: &2165400380 !ruby/object:Gem::Requirement
72
+ requirement: &2152644260 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: '0'
78
78
  type: :runtime
79
79
  prerelease: false
80
- version_requirements: *2165400380
80
+ version_requirements: *2152644260
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: pdfkit
83
- requirement: &2165399960 !ruby/object:Gem::Requirement
83
+ requirement: &2152643760 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ! '>='
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: '0'
89
89
  type: :runtime
90
90
  prerelease: false
91
- version_requirements: *2165399960
91
+ version_requirements: *2152643760
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: prawn
94
- requirement: &2165399540 !ruby/object:Gem::Requirement
94
+ requirement: &2152643340 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ! '>='
@@ -99,7 +99,7 @@ dependencies:
99
99
  version: '0'
100
100
  type: :runtime
101
101
  prerelease: false
102
- version_requirements: *2165399540
102
+ version_requirements: *2152643340
103
103
  description: Use the medivo platform to find lab locations, make labcorp appointments,
104
104
  place lab orders
105
105
  email:
@@ -292,7 +292,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
292
292
  version: '0'
293
293
  segments:
294
294
  - 0
295
- hash: 445725312678578910
295
+ hash: -677947114815141566
296
296
  required_rubygems_version: !ruby/object:Gem::Requirement
297
297
  none: false
298
298
  requirements:
@@ -301,7 +301,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
301
  version: '0'
302
302
  segments:
303
303
  - 0
304
- hash: 445725312678578910
304
+ hash: -677947114815141566
305
305
  requirements: []
306
306
  rubyforge_project:
307
307
  rubygems_version: 1.6.2