Sha256: c00df6645201c4d7a3be85cc4baf651d51374f83ead0af43e719139f36e26b4a

Contents?: true

Size: 850 Bytes

Versions: 3

Compression:

Stored size: 850 Bytes

Contents

# spec for file-sniffing functions

require "spec_helper"

describe "delimiter sniffing" do
  it "should find tab delimiter" do
    filename = File.dirname(__FILE__) + "/../data/tabbed_data.txt"
    results = Masticate.sniff(filename)
    results[:col_sep].should == "\t"
    results[:field_counts].should == {6 => 5}
  end

  it "should find pipe delimiter" do
    filename = File.dirname(__FILE__) + "/../data/pipe_data.txt"
    results = Masticate.sniff(filename)
    results[:col_sep].should == '|'
    results[:field_counts].should == {6 => 5}
  end

  it "should recognize quotes in CSV sources" do
    filename = File.dirname(__FILE__) + "/../data/quoted_csv_data.txt"
    results = Masticate.sniff(filename)
    results[:col_sep].should == ','
    results[:quote_char].should == '"'
    results[:field_counts].should == {14 => 100}
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
masticate-0.1.3 spec/lib/sniffer_spec.rb
masticate-0.1.1 spec/lib/sniffer_spec.rb
masticate-0.1.0 spec/lib/sniffer_spec.rb