Browse Source

Better regression tests for roo

dev
Andy Meneely 11 years ago
parent
commit
25773a8ee5
  1. 2
      CHANGELOG.md
  2. 2
      lib/squib/api/data.rb
  3. 19
      spec/api/api_data_spec.rb
  4. BIN
      spec/data/xlsx/basic.xlsx
  5. BIN
      spec/data/xlsx/formulas.xlsx
  6. 4
      spec/spec_helper.rb
  7. 5
      squib.sublime-project

2
CHANGELOG.md

@ -4,7 +4,7 @@ Squib follows [semantic versioning](http://semver.org).
## v0.6.0 / Unreleased
Features:
* Upgraded roo (Excel parsing) to 2.0.0. Nothing major for Squib users, just keeping up with the times.
* Upgraded roo (Excel parsing) to 2.0.0. Nothing major for Squib users, just keeping up with the times. ()
Bugs:
* Fixed global text hinting (#63)

2
lib/squib/api/data.rb

@ -32,7 +32,7 @@ module Squib
data[header] = []
(s.first_row + 1).upto(s.last_row) do |row|
cell = s.cell(row,col)
# Roo hack for avoiding unnecessary .0's on whole integers
# Roo hack for avoiding unnecessary .0's on whole integers (https://github.com/roo-rb/roo/issues/139)
cell = s.excelx_value(row,col) if s.excelx_type(row,col) == [:numeric_or_formula, 'General']
data[header] << cell
end#row

19
spec/api/api_data_spec.rb

@ -28,4 +28,23 @@ describe Squib::Deck do
})
end
end
context '#xlsx' do
it 'loads basic xlsx data' do
expect(Squib.xlsx(file: xlsx_file('basic.xlsx'))).to eq({
'Name' => %w(Larry Curly Mo),
'General Number' => %w(1 2 3), #general types always get loaded as strings with no conversion
'Actual Number' => [4.0, 5.0, 6.0], #numbers get auto-converted to integers
})
end
it 'loads xlsx with formulas' do
expect(Squib.xlsx(file: xlsx_file('formulas.xlsx'))).to eq({
'A' => %w(1, 2),
'B' => %w(3, 4),
'Sum' => %w(4, 6),
})
end
end
end

BIN
spec/data/xlsx/basic.xlsx

Binary file not shown.

BIN
spec/data/xlsx/formulas.xlsx

Binary file not shown.

4
spec/spec_helper.rb

@ -32,6 +32,10 @@ def csv_file(file)
"#{File.expand_path(File.dirname(__FILE__))}/data/csv/#{file}"
end
def xlsx_file(file)
"#{File.expand_path(File.dirname(__FILE__))}/data/xlsx/#{file}"
end
def overwrite_sample(sample_name, log)
# Use this to overwrite the regression with current state
File.open(sample_regression_file(sample_name), 'w+:UTF-8') do |f|

5
squib.sublime-project vendored

@ -43,6 +43,11 @@
"shell_cmd": "rspec spec/graphics/graphics_text_spec.rb",
"working_dir": "${project_path:${folder}}"
},
{
"name": "rspec spec/api/api_data_spec.rb",
"shell_cmd": "rspec spec/api/api_data_spec.rb",
"working_dir": "${project_path:${folder}}"
},
],

Loading…
Cancel
Save