Sha256: 48a5c50ffeebe109d0c558be2df499d631f13ed464692dd2e4919d4ccba4bc36
Contents?: true
Size: 1.69 KB
Versions: 5
Compression:
Stored size: 1.69 KB
Contents
module ActiveOLAP::Test module Assertions # tests whether Active OLAP is enabled for a given class, by checking # whether the class responds to certain methods like olap_query def assert_active_olap_enabled(klass, message = "Active OLAP is not enabled for this class!") assert klass.respond_to?(:active_olap_dimensions), message assert klass.respond_to?(:active_olap_aggregates), message assert klass.respond_to?(:olap_query), message assert klass.respond_to?(:olap_drilldown), message end # tests whether a given cube is a valid Active OLAP cube and has the expected dimensions # you can specify the number of dimenions as an integer (say n), or as an array of n integers, # in which each element is the number of categories that should be in that dimension. You can # use :unknown if this is not known beforehand # # examples: # # assert_active_olap_cube cube, 2 # => checks for the existence of two dimensions # # assert_active_olap_cube cube, [3, :unknown] # => Checks for the existence of two dimensions. # - The first dimension should have 3 catgeories # - The number of categories in the second dimension is unknown def assert_active_olap_cube(cube, dimensions = nil) assert_kind_of ActiveOLAP::Cube, cube if dimensions.kind_of?(Array) assert_equal dimensions.length, cube.depth dimensions.each_with_index do |category_count, index| assert_equal category_count, cube.dimensions[index].categories.length unless category_count == :unknown end elsif dimensions.kind_of?(Numeric) assert_equal dimensions, cube.depth end end end end
Version data entries
5 entries across 5 versions & 2 rubygems