Sha256: 70cdf23e408608e6e1cb4391cc45d2e8ecc42888b0343ac35d4d0d934c2e44f1

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 KB

Contents

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
require 'to_xls'

def mock_model(name, attributes)
  attributes[:attributes] = attributes.clone
  mock(name, attributes)
end

def mock_company(name, address)
  mock_model( name, :name => name, :address => address )
end

def mock_user(name, age, email, company)
  user = mock_model(name, :name => name, :age => age, :email => email)
  user.stub!(:company).and_return(company)
  user
end

def mock_users
  acme = mock_company('Acme', 'One Road')
  eads = mock_company('EADS', 'Another Road')

  [ mock_user('Peter', 20, 'peter@gmail.com', acme),
    mock_user('John',  25, 'john@gmail.com', acme),
    mock_user('Day9',  27, 'day9@day9tv.com', eads)
  ]
end

def check_sheet(sheet, array)
  sheet.rows.each_with_index do |row, i|
    row.should == array[i]
  end
end

def make_book(array, options={})
  book = Spreadsheet::Workbook.new
  ToXls::Writer.new(array, options).write_book(book)
  book
end

def check_format(sheet, header_format, cell_format)
  sheet.rows.each_with_index do |row, i|
    hash = i == 0 ? header_format : cell_format
    compare_hash_format(hash, row.default_format)
  end
end

def compare_hash_format(hash, format)
  hash.each do |key, value| 
    format.font.send(key).should == value
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
to_xls-1.5.3 spec/spec_helper.rb
to_xls-1.5.2 spec/spec_helper.rb
to_xls-1.5.1 spec/spec_helper.rb
to_xls-1.5.0 spec/spec_helper.rb