Sha256: a0818aa088c6eae53c4514c50d33efaeb5af917b2dd01cd508b989816a868f6b

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

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
      expect(segment.accepts?(:OBR)).to be true
      expect(segment.child_types).to include :OBR
    end
  end

  describe "Adding children has_children and add_child_type" do
    subject do
      segment_instance = segment_class.new
      [:accepts?, :child_types, :children].each do |method|
        expect(segment_instance.respond_to?(method)).to 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
        expect(segment_instance.respond_to?(:children)).to 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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-hl7-1.3.3 spec/segment_list_storage_spec.rb
ruby-hl7-1.3.2 spec/segment_list_storage_spec.rb
ruby-hl7-1.3.1 spec/segment_list_storage_spec.rb
ruby-hl7-1.3.0 spec/segment_list_storage_spec.rb