Sha256: eaf5c1a0b759bf5e7b28db37d2e834c4a62365b7930a575dec30adc8e29b9b13

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

require "test_helper"

class PlainRubyObjectTest < ActiveSupport::TestCase

  def setup
    @path = 'tmp/plain_ruby_object'
    FileUtils.mkdir_p(@path)

    DatabaseCleaner.start
  end

  def test_csv
    assert_raise SpreadsheetArchitect::Exceptions::NoInstancesError do
      PlainRubyObject.to_csv
    end

    instances = 3.times.map{|_| PlainRubyObject.new}
    data = PlainRubyObject.to_csv(instances: instances)

    File.open(File.join(@path, 'csv.csv'), 'w+b') do |f|
      f.write data
    end
  end

  def test_ods
    assert_raise SpreadsheetArchitect::Exceptions::NoInstancesError do
      PlainRubyObject.to_ods
    end

    instances = 3.times.map{|_| PlainRubyObject.new}
    data = PlainRubyObject.to_ods(instances: instances)

    File.open(File.join(@path, 'ods.ods'), 'w+b') do |f|
      f.write data
    end
  end

  def test_xlsx
    assert_raise SpreadsheetArchitect::Exceptions::NoInstancesError do
      PlainRubyObject.to_xlsx
    end

    instances = 3.times.map{|_| PlainRubyObject.new}
    data = PlainRubyObject.to_xlsx(instances: instances)

    File.open(File.join(@path, 'xlsx.xlsx'), 'w+b') do |f|
      f.write data
    end
  end

  def teardown
    DatabaseCleaner.clean
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spreadsheet_architect-2.0.2 test/rails_app/test/models/plain_ruby_object_test.rb
spreadsheet_architect-2.0.1 test/rails_app/test/models/plain_ruby_object_test.rb
spreadsheet_architect-2.0.0 test/rails_app/test/models/plain_ruby_object_test.rb