forked from ruby-hl7/ruby-hl7
/
segment_list_storage_spec.rb
47 lines (39 loc) · 1.29 KB
/
segment_list_storage_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'spec_helper'
class SegmentNoChildren< HL7::Message::Segment
end
class SegmentWithChildren < HL7::Message::Segment
has_children [:NTE,:ORC,:SPM]
end
describe HL7::Message::SegmentListStorage do
describe "self#add_child_type" do
it "should allow to add a new segment type as child" do
SegmentWithChildren.add_child_type :OBR
segment = SegmentWithChildren.new
segment.accepts?(:OBR).should be_true
segment.child_types.should include :OBR
end
end
describe "Adding children has_children and add_child_type" do
subject do
segment_instance = segment_class.new
methods = [:accepts?, :child_types, :children].each do |method|
segment_instance.respond_to?(method).should be_true
end
end
context "when child_types is not present" do
let(:segment_class){ SegmentNoChildren }
it "by adding add_child_type should respond to the children methods" do
segment_instance = segment_class.new
segment_instance.respond_to?(:children).should be_false
segment_class.add_child_type(:OBR)
subject
end
end
context "when child_types is present" do
let(:segment_class){ SegmentWithChildren }
it "should respond to the children methods" do
subject
end
end
end
end