Sha256: a4da1e939d76e06e4a0123067151a0317060b76258c1d608588e3fd52409cfeb

Contents?: true

Size: 822 Bytes

Versions: 4

Compression:

Stored size: 822 Bytes

Contents

# encoding: UTF-8
require 'spec_helper'

describe 'dynamic segment definition' do
  context 'general' do
    it 'accepts a block with a parameter' do
      seg = HL7::Message::Segment.new do |s|
        s.e0 = "MSK"
        s.e1 = "1234"
        s.e2 = "5678"
      end

      expect(seg.to_s).to eq "MSK|1234|5678"
    end

    it 'accepts a block without a parameter' do
      seg = HL7::Message::Segment.new do
        e0 "MSK"
        e1 "1234"
        e2 "5678"
      end

      expect(seg.to_s).to eq "MSK|1234|5678"
    end

    it "doesn't pollute the caller namespace" do
      seg = HL7::Message::Segment.new do |s|
        s.e0 = "MSK"
        s.e1 = "1234"
        s.e2 = "5678"
      end

      expect { e3 "TEST" }.to raise_error(NoMethodError)
      expect(seg.to_s).to eq "MSK|1234|5678"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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