Sha256: 39b1535a15a0896fbbcfa9b106b3404ea2d415a480f2b5db6e5e339db46228f5

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

describe Pipio, ".parse" do
  context "with bad input" do
    it "returns false when file is not text or html" do
      expect(Pipio.parse(non_html_or_txt_path, aliases)).to be_falsey
    end

    it "returns false for nonexistent files" do
      expect(Pipio.parse('i_do_not_exist.html', aliases)).to be_falsey
      expect(Pipio.parse('i_do_not_exist.txt', aliases)).to be_falsey
    end

    def non_html_or_txt_path
      'logfile.foobar'
    end
  end

  context "with good input" do
    context "for a text file" do
      it "returns a Chat instance" do
        result = Pipio.parse(text_logfile_path, aliases)
        expect(result).to be_instance_of(Pipio::Chat)
      end
    end

    context "for an htm file" do
      it "returns a Chat instance" do
        result = Pipio.parse(htm_logfile_path, aliases)
        expect(result).to be_instance_of(Pipio::Chat)
      end
    end

    context "for an html file" do
      it "returns a Chat instance" do
        result = Pipio.parse(html_logfile_path, aliases)
        expect(result).to be_instance_of(Pipio::Chat)
      end
    end
  end

  def spec_directory
    File.dirname(__FILE__)
  end

  def logfile_path
    Pathname.new(File.join(spec_directory, "support", "logfiles"))
  end

  def text_logfile_path
    logfile_path.join("2006-12-21.223606.txt")
  end

  def htm_logfile_path
    logfile_path.join("2008-01-15.071445-0500PST.htm")
  end

  def html_logfile_path
    logfile_path.join("2008-01-15.071445-0500PST.html")
  end

  def aliases
    ''
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pipio-0.0.1 spec/pipio_spec.rb