Test Plugin C0 Coverage Information - RCov

oddbdat_export.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
oddbdat_export.rb 92 75
95.65%
94.67%

Key

Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.

Coverage Details

1 #!/usr/bin/env ruby
2 # TestOddbDatExport -- oddb -- 07.02.2011 -- mhatakeyama@ywesee.com
3 
4 $: << File.expand_path('..', File.dirname(__FILE__))
5 $: << File.expand_path("../../src", File.dirname(__FILE__))
6 
7 require 'stub/oddbdat_export'
8 require 'test/unit'
9 require 'flexmock'
10 require 'date'
11 
12 
13 module ODDB
14   module OdbaExporter
15     class StubDRbObject
16       def export_oddbdat(*args)
17         ['export_oddbdat']
18       end
19       def compress_many(*args)
20       end
21     end
22     class OddbDatExport
23       remove_const :EXPORT_SERVER
24       EXPORT_SERVER = StubDRbObject.new
25       @@today = Date.new(2011,2,3)
26     end
27     class TestOddbDatExport < Test::Unit::TestCase
28       include FlexMock::TestCase
29       def setup
30         @app = flexmock('app') do |ap|
31          ap.should_receive(:atc_classes).and_return(flexmock('atc_classes') do |atc|
32             atc.should_receive(:values).and_return([])
33           end)
34           ap.should_receive(:each_galenic_form).and_yield(flexmock('galform') do |gal|
35             gal.should_receive(:odba_id).and_return('gal.odba_id')
36           end)
37           ap.should_receive(:substances).and_return([])
38           ap.should_receive(:companies).and_return([])
39         end
40         @oddbdatexport = OddbDatExport.new(@app)
41 
42      end
43       def test_export
44         flexstub(@app) do |ap|
45           ap.should_receive(:each_package).and_yield(flexmock('pac') do |pac|
46             pac.should_receive(:odba_id).and_return('pac.odba_id')
47             pac.should_receive(:parts).and_return('not empty')
48           end)
49         end
50 
51         # white box test: check 'files' value
52         flexstub(OddbDatExport::EXPORT_SERVER) do |drb|
53           expected = ["export_oddbdat"] * 5
54           drb.should_receive(:compress_many).with(String, String, expected)
55         end
56 
57         # black box test
58         assert_equal([], @oddbdatexport.export)
59       end
60       def test_export__dose_missing
61         flexstub(@app) do |ap|
62           ap.should_receive(:each_package).and_yield(flexmock('pac') do |pac|
63             pac.should_receive(:odba_id).and_return('pac.odba_id')
64             pac.should_receive(:parts).and_return('')
65             pac.should_receive(:basename).and_return('pac.basename')
66             pac.should_receive(:iksnr).and_return('pac.iksnr')
67             pac.should_receive(:"sequence.seqnr").and_return('pac.sequence.seqnr')
68             pac.should_receive(:ikscd).and_return('pac.iksce')
69           end)
70         end
71  
72         expected = [["pac.basename", "pac.iksnr", "pac.sequence.seqnr", "pac.iksce"]]
73         assert_equal(expected, @oddbdatexport.export)
74       end
75       def test_export_fachinfos
76         flexstub(@app) do |ap|
77           ap.should_receive(:fachinfos).and_return([])
78         end
79 
80         # white box test: check 'files' value
81         flexstub(OddbDatExport::EXPORT_SERVER) do |drb|
82           expected = "export_oddbdat"
83           drb.should_receive(:compress).with(String, expected)
84         end
85  
86         # black box test
87         assert_equal(nil, @oddbdatexport.export_fachinfos)
88       end
89     end
90   end
91 end
92 

Generated on Mon Feb 07 09:23:52 +0100 2011 with rcov 0.9.8