Sha256: eddd34e224e76d807522f8fe229b55a1d3d34fae4872daa420337febbf8a4050

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

describe Pipio::TextLogParser do
  describe "#parse" do
    it "returns a Chat with the correct number of lines" do
      chat = build_chat do |b|
        b.message
      end

      expect(chat.messages.size).to eq(1)
    end

    it "returns a Chat with the correct message type" do
      chat = build_chat do |b|
        b.message
      end

      expect(chat.messages.first).to be_instance_of(Pipio::XMLMessage)
    end

    it "returns a Chat with the correct data" do
      message = build_chat do |b|
        b.first_line time: '2006-12-21 22:36:06', from: 'awesome SN'
        b.message from_alias: 'Gabe B-W', time: '22:36:11',
          text: "what are you doing tomorrow?"
      end.messages.first

      expect(message.sender_screen_name).to eq("awesomesn")
      expect(message.body).to eq("what are you doing tomorrow?")
      expect(message.sender_alias).to eq("Gabe B-W")
      expect(message.time).to eq(Time.parse('2006-12-21 22:36:11').utc)
    end
  end

  def build_chat(aliases = 'Gabe B-W', &block)
    path = create_chat_file('file.txt', &block).path
    Pipio::TextLogParser.new(path, aliases).parse
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pipio-0.0.1 spec/pipio/parsers/text_log_parser_spec.rb