Sha256: 8a663c4c4559e51c9b5b729efb70e0a74b3c0b2b93fbfc59c0af6a3fb28036a2

Contents?: true

Size: 886 Bytes

Versions: 3

Compression:

Stored size: 886 Bytes

Contents

require 'spec_helper'

describe Xdrgen::OutputFile, "#balance_after" do
  let(:output_path){ "#{SPEC_ROOT}/../tmp/balanced.txt"}
  let(:unbalanced) do
    <<-EOS.strip_heredoc
    attribute :hello, XDR::UnsignedInt
    attribute :i_am_a_long_field, XDR::UnsignedInt
    attribute :s, XDR::UnsignedInt
    EOS
  end

  let(:actual){ IO.read(output_path) }
  let(:balanced) do
    <<-EOS.strip_heredoc
    attribute :hello,             XDR::UnsignedInt
    attribute :i_am_a_long_field, XDR::UnsignedInt
    attribute :s,                 XDR::UnsignedInt
    EOS
  end

  subject{ Xdrgen::OutputFile.new(output_path) }

  after(:each){ FileUtils.rm output_path }

  it "balanaces the input string on each line after splitting on the provided regex" do
    subject.balance_after /.+?,/ do
      subject.puts unbalanced
    end
    subject.close
    expect(actual).to eq(balanced)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
xdrgen-0.1.1 spec/lib/xdrgen/output_file_spec.rb
xdrgen-0.1.0 spec/lib/xdrgen/output_file_spec.rb
xdrgen-0.0.1 spec/lib/xdrgen/output_file_spec.rb