Sha256: 3896de56e3fe0841979828afb4cb19d86641280a63b5fbeb8a06d1eea9097f45

Contents?: true

Size: 610 Bytes

Versions: 16

Compression:

Stored size: 610 Bytes

Contents

require 'rspec/matchers'
require 'simple_xlsx_reader'

RSpec::Matchers.define :have_values_in_xlsx_sheet do |expect_values|
  match do |data|
    @actual_values = extract_values(data)
    expect(@actual_values).to eq expect_values
  end


  failure_message do
    RSpec::Expectations.differ.diff_as_object(@actual_values, expect_values)
  end

  private

  def extract_values(data)
    Tempfile.open(%w[actual .xlsx], Dir.tmpdir, encoding: 'BINARY') do |f|
      f.write data
      f.flush

      sheet = SimpleXlsxReader::Document.new(f.path).sheets.first
      [sheet.headers, *sheet.data]
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
adhoq-1.0.2 spec/support/have_values_in_xlsx_sheet_matcher.rb
adhoq-1.0.1 spec/support/have_values_in_xlsx_sheet_matcher.rb
adhoq-1.0.0 spec/support/have_values_in_xlsx_sheet_matcher.rb
adhoq-0.5.0 spec/support/have_values_in_xlsx_sheet_matcher.rb
adhoq-0.5.0.beta1 spec/support/have_values_in_xlsx_sheet_matcher.rb
adhoq-0.4.0 spec/support/have_values_in_xlsx_sheet_matcher.rb
adhoq-0.3.0 spec/support/have_values_in_xlsx_sheet_matcher.rb
adhoq-0.2.0 spec/support/have_values_in_xlsx_sheet_matcher.rb
adhoq-0.1.2 spec/support/have_values_in_xlsx_sheet_matcher.rb
adhoq-0.1.1 spec/support/have_values_in_xlsx_sheet_matcher.rb
adhoq-0.1.0 spec/support/have_values_in_xlsx_sheet_matcher.rb
adhoq-0.0.7 spec/support/have_values_in_xlsx_sheet_matcher.rb
adhoq-0.0.6 spec/support/have_values_in_xlsx_sheet_matcher.rb
adhoq-0.0.5 spec/support/have_values_in_xlsx_sheet_matcher.rb
adhoq-0.0.4 spec/support/have_values_in_xlsx_sheet_matcher.rb
adhoq-0.0.3 spec/support/have_values_in_xlsx_sheet_matcher.rb