Sha256: 306d3fd5679fdb6531c4afb0b5f686fd02f6921abbe771a495b43a6f94b75359

Contents?: true

Size: 1.92 KB

Versions: 4

Compression:

Stored size: 1.92 KB

Contents

require 'spec_helper'

describe ExcelAbstraction::Sheet do
  let(:spreadsheet) { ExcelAbstraction::SpreadSheet.new }

  subject { spreadsheet.workbook.active_sheet }

  describe "#header" do
    it "sets the header" do
      test_excel_file do |file|
        excel = create_excel(file, spreadsheet) do
          subject.header("Foo")
        end

        expect(excel.cell("A", 1)).to eq "Foo"
        expect(excel.font("A", 1)).to be_bold
      end
    end
  end

  describe "#headers" do
    it "sets the headers" do
      test_excel_file do |file|
        excel = create_excel(file, spreadsheet) do
          subject.header(["Foo", "Bar"])
        end

        expect(excel.cell("A", 1)).to eq "Foo"
        expect(excel.font("A", 1)).to be_bold
        expect(excel.cell("B", 1)).to eq "Bar"
        expect(excel.font("B", 1)).to be_bold
      end
    end
  end

  describe "#cell" do
    it "sets the cell value" do
      test_excel_file do |file|
        excel = create_excel(file, spreadsheet) do
          subject.cell("Foo")
        end

        expect(excel.cell("A", 1)).to eq "Foo"
      end
    end
  end

  describe "#cells" do
    it "sets the cell values" do
      test_excel_file do |file|
        excel = create_excel(file, spreadsheet) do
          subject.cells(["Foo", "Bar"])
        end

        expect(excel.cell("A", 1)).to eq "Foo"
        expect(excel.cell("B", 1)).to eq "Bar"
      end
    end
  end

  describe "#merge" do
    it "merges the cells" do
      test_excel_file do |file|
        excel = create_excel(file, spreadsheet) do
          subject.merge(1, "Foo")
          subject.cell("Bar")
        end

        expect(excel.cell("A", 1)).to eq "Foo"
        expect(excel.cell("B", 1)).to be_nil
        expect(excel.cell("C", 1)).to eq "Bar"
      end
    end
  end

  describe "#style_row" do
    # hard to test; already tested manually
  end

  describe "#style_col" do
    # hard to test; already tested manually
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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