Sha256: 6b3765f5c27652d78aca0bc370b66405e98f183d3ae483095af616e5f77ae49a

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require File.expand_path('../lib/log_slice', File.dirname(__FILE__))
require 'helper'

describe LogSlice::DateRange do

  let(:file_contents) {
    %{
[2012-08-31 17:19:45] test 1
[2012-08-31 17:19:57] test 2
[2012-08-31 17:19:57] test 3
[2012-08-31 17:20:12] test 4
[2012-08-31 17:20:24] test 5
[2012-08-31 17:20:35] test 6
[2012-08-31 17:21:02] test 7
[2012-08-31 17:21:09] test 8
    }.strip
  }

  it "works" do
    start_date = '2012-08-31 17:20:00'
    end_date = '2012-08-31 17:21:00'
    lines = []
    LogSlice::DateRange.new(string_to_file(file_contents), start_date, end_date).each do |line|
      lines << line.strip
    end
    lines.should == [
      "[2012-08-31 17:20:12] test 4",
      "[2012-08-31 17:20:24] test 5",
      "[2012-08-31 17:20:35] test 6"
    ]
  end

  it "works without an end date" do
    start_date = '2012-08-31 17:20:00'
    lines = []
    LogSlice::DateRange.new(string_to_file(file_contents), start_date, nil).each do |line|
      lines << line.strip
    end
    lines.should == [
      "[2012-08-31 17:20:12] test 4",
      "[2012-08-31 17:20:24] test 5",
      "[2012-08-31 17:20:35] test 6",
      "[2012-08-31 17:21:02] test 7",
      "[2012-08-31 17:21:09] test 8"
    ]
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
log_slice-0.4 spec/log_slice_date_range_spec.rb