Sha256: a4841a84b881eb8d9a1259f08d99d6d9a5399b698f837cfd716e63b12678dcb6

Contents?: true

Size: 855 Bytes

Versions: 1

Compression:

Stored size: 855 Bytes

Contents

# frozen_string_literal: true

require 'feature_test'

class TestListEvents < FeatureTest
  feature :list_events do
    report = Thinreports::Report.new layout: template_path

    report.list.header title: 'Prices'

    report.list do |list|
      price_for = { page: 0, all: 0 }

      list.on_page_finalize do
        price_for[:all] += price_for[:page]
        price_for[:page] = 0
      end

      list.on_page_footer_insert do |footer|
        footer.item(:price).value(price_for[:page])
      end

      list.on_footer_insert do |footer|
        footer.item(:price).value(price_for[:all])
      end

      [100, 200, 250, 50, 100, 20, 30, 50, 100, 100].each do |price|
        list.add_row price: price
        # Calculate sum price for each page of list
        price_for[:page] += price
      end
    end

    assert_pdf report.generate
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thinreports-0.10.3 test/features/list_events/test_list_events.rb