Sha256: e662db25017a10743b52f26ae86c804919f6912abea59450cfe761863e1091a9

Contents?: true

Size: 1.34 KB

Versions: 8

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

describe Colander do
  describe ".parse" do
    it "should raise error if no file path is passed" do
      lambda{
        Colander.parse
      }.should raise_exception(ArgumentError)
    end

    it "should raise error if file is unsupported" do
      lambda {
        Colander.parse("foo.bar")
      }.should raise_error(Colander::InvalidFile)
    end

    it "should not raise error if a file path is passed" do
      lambda{
        Colander.parse("/file/path")
      }.should_not raise_exception(ArgumentError)
    end

    it "accepts an option file name and returns correct parser" do
      Colander::Parser::Xls.any_instance.stub(:parse)
      Colander.parse("/file/path", "apa.xls").should be_a Colander::Parser::Xls
    end

    it "should recognize a xls file and return correct parser" do
      path = "/foo/apa.xls"
      Colander::Parser::Xls.any_instance.stub(:parse)
      Colander.parse(path).should be_a Colander::Parser::Xls
    end

    it "should recognize a xlsx file and return correct parser" do
      path = "/foo/apa.xlsx"
      Colander::Parser::Xlsx.any_instance.stub(:parse)
      Colander.parse(path).should be_a Colander::Parser::Xlsx
    end

    it "should invoke parse method on the parser" do
      Colander::Parser::Xlsx.any_instance.should_receive(:parse)
      Colander.parse("/foo/bar.xlsx")
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
colander-0.2.1 spec/colander_spec.rb
colander-0.2.0 spec/colander_spec.rb
colander-0.1.2 spec/colander_spec.rb
colander-0.1.1 spec/colander_spec.rb
colander-0.1.0 spec/colander_spec.rb
colander-0.0.3 spec/colander_spec.rb
colander-0.0.2 spec/colander_spec.rb
colander-0.0.1 spec/colander_spec.rb