Sha256: e992b64b602270cd4bc59e431537bf9902fd7e0c71d363a853b549bc75f0aba8

Contents?: true

Size: 1.83 KB

Versions: 5

Compression:

Stored size: 1.83 KB

Contents

require 'spec_helper'

describe Colander::Parser::Xls do
  describe "#parse" do
    it "stores found emails" do
      parser = Colander::Parser::Xls.new("file/path")
      parser.should_receive(:parse_file).and_return("bruce@wayne.com")
      parser.parse
      parser.emails.sort.should eql(["bruce@wayne.com"])
    end

    it "raises exception if file is invalid" do
      parser = Colander::Parser::Xls.new("./#{__FILE__}")
      lambda {
        parser.parse
      }.should raise_error(Colander::InvalidFile)
    end

    it "wraps errors and returns InvalidFile" do
      parser = Colander::Parser::Xls.new("file/path")
      parser.should_receive(:parse_file).and_raise(RuntimeError.new("FUUU"))
      expect {
        parser.parse
      }.to raise_error(Colander::InvalidFile)
    end

    it "retreives emails from an 95-excel spreadsheet" do
      parser = Colander::Parser::Xls.new("spec/fixtures/excel95.xls")
      parser.parse
      parser.emails.sort.should eql(["markus.nordin@mynewsdesk.com", "markus@hej.se", "sven@bertil.se", "Adam.A@hotmail.com", "apa@elabs.se", "liam@neeson.net", "david@mynewsdesk.com"].sort)
    end
    it "retreives emails from an xls spreadsheet" do
      parser = Colander::Parser::Xls.new("spec/fixtures/old-format.xls")
      parser.parse
      parser.emails.sort.should eql(["markus.nordin@mynewsdesk.com", "markus@hej.se", "sven@bertil.se", "Adam.A@hotmail.com", "apa@elabs.se", "liam@neeson.net", "david@mynewsdesk.com"].sort)
    end
    it "retreives emails from an 95-excel spreadsheet without file suffix" do
      parser = Colander::Parser::Xls.new("spec/fixtures/excel95-without-file-suffix")
      parser.parse
      parser.emails.sort.should eql(["markus.nordin@mynewsdesk.com", "markus@hej.se", "sven@bertil.se", "Adam.A@hotmail.com", "apa@elabs.se", "liam@neeson.net", "david@mynewsdesk.com"].sort)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
colander-0.2.1 spec/xls_spec.rb
colander-0.2.0 spec/xls_spec.rb
colander-0.1.2 spec/xls_spec.rb
colander-0.1.1 spec/xls_spec.rb
colander-0.1.0 spec/xls_spec.rb