Sha256: 4a398cfccd1630885def3e3310a77d46f661298753b81686adb749eae53d5cb0

Contents?: true

Size: 800 Bytes

Versions: 4

Compression:

Stored size: 800 Bytes

Contents

require 'spec_helper'
require 'roo'

describe ExcelAbstraction::SpreadSheet do
  describe "#close" do
    it "closes the excel file" do
      subject.close
      expect(subject).to be_closed
    end

    context "when a block is passed" do
      it "executes the block before closing the excel file" do
        test = 0
        subject.close { test += 1 }
        expect(test).to eq(1)
        expect(subject).to be_closed
      end
    end
  end

  describe "#to_s" do
    it "closes the file and returns it's data" do
      file = Tempfile.new('xls')
      file.write subject.to_s
      file.close

      expect {
        Roo::Excel.new(file.path, packed: nil, file_warning: :ignore)
      }.to_not raise_exception

      File.unlink(file.path)
      expect(subject).to be_closed
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
excel_templating-0.4.2 spec/excel_abstraction/spread_sheet_spec.rb
excel_templating-0.4.1 spec/excel_abstraction/spread_sheet_spec.rb
excel_templating-0.4.0 spec/excel_abstraction/spread_sheet_spec.rb
excel_templating-0.3.2 spec/excel_abstraction/spread_sheet_spec.rb