Sha256: 28006a4e375822f89a3dea110e14f1aabd6534fce167a666204e83be7545a08e

Contents?: true

Size: 826 Bytes

Versions: 5

Compression:

Stored size: 826 Bytes

Contents

require_relative '../../test_helper'
require 'open3'
require 'shellwords'

def cmd_to_sys(command)
  Open3.popen3(command) do |stdin, stdout, stderr|
    [stdout.read, stderr.read]
  end
end

describe DocParser do
  it 'should run the example without problems' do
    curwd = Dir.getwd
    Dir.mktmpdir do |dir|
      Dir.chdir(dir)
      example_file = Shellwords.escape(File.join($ROOT_DIR, 'example.rb'))
      out, err = cmd_to_sys '/usr/bin/env ruby ' + example_file
      err.must_be_empty
      rows = out.scan(/(\d+) rows/).flatten
      rows.length.must_equal 5
      row_lengths = rows.group_by { |elem| elem.to_i }
      row_lengths.length.must_equal 1
      # HaD: 40 pages of 7 articles
      row_lengths.keys.first.must_equal(7 * 40)
      out.must_match(/Done processing/)
    end
    Dir.chdir(curwd)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
docparser-0.1.4 test/lib/docparser/blackbox_test.rb
docparser-0.1.3 test/lib/docparser/blackbox_test.rb
docparser-0.1.2 test/lib/docparser/blackbox_test.rb
docparser-0.1.1 test/lib/docparser/blackbox_test.rb
docparser-0.1.0 test/lib/docparser/blackbox_test.rb