Sha256: 6d7d909c158fb5b56a7056c8a432b4d43d7e6016f261ec29ed50a5e5e56b5a8e

Contents?: true

Size: 1003 Bytes

Versions: 5

Compression:

Stored size: 1003 Bytes

Contents

require'spec_helper'
describe 'Axlsx template handler' do

  AB = ActionView::Template::Handlers::AxlsxBuilder
  VT = Struct.new(:source)

  let( :handler ) { AB.new }

  let( :template ) do
    VT.new("wb = xlsx_package.workbook;\nwb.add_worksheet(name: 'Test') do |sheet|\n\tsheet.add_row ['one', 'two', 'three']\n\tsheet.add_row ['a', 'b', 'c']\nend\n")
  end

  context "Rails #{Rails.version}" do
    # for testing if the author is set
    # before do
      # Rails.stub_chain(:application, :config, :axlsx_author).and_return( 'Elmer Fudd' )
    # end

    it "has xlsx format" do
      handler.default_format.should == Mime::XLSX
    end

    it "compiles to an excel spreadsheet" do
      xlsx_package, wb = nil
      eval( AB.call template )
      xlsx_package.serialize('/tmp/axlsx_temp.xlsx')
      expect{ wb = Roo::Excelx.new('/tmp/axlsx_temp.xlsx') }.to_not raise_error
      wb.cell(2,3).should == 'c'
    end

    #TODO:
    # Test if author field is set - does roo parse that?
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
axlsx_rails-0.4.0 spec/axlsx_builder_spec.rb
axlsx_rails-0.3.0 spec/axlsx_builder_spec.rb
axlsx_rails-0.2.1 spec/axlsx_builder_spec.rb
axlsx_rails-0.2.0 spec/axlsx_builder_spec.rb
axlsx_rails-0.1.5 spec/axlsx_builder_spec.rb