Module: TheArrayComparator::TestingHelper

Defined in:
lib/the_array_comparator/testing_helper.rb,
lib/the_array_comparator/testing_helper/data_set.rb,
lib/the_array_comparator/testing_helper/test_data.rb

Overview

helper for tests

Defined Under Namespace

Classes: DataSet, TestData

Instance Method Summary collapse

Instance Method Details

#generate_testdata(options) ⇒ Array

Generate data for the tests

Parameters:

  • options (Hash)

Options Hash (options):

  • :keywords (Array)

    the keywords which should be hidden in the data

  • :raw_data (Array)

    the data which should be used to hide the keywords

  • :count_of_data (Integer)

    how much raw data should be generated if none is given

Returns:

  • (Array)

    the testdata (raw_data + keywords)



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/the_array_comparator/testing_helper.rb', line 21

def generate_testdata(options)
  opts = {
    keywords: [],
    raw_data: [],
    count_of_data: 100,
  }.merge options

  raw_data = options[:raw_data] || Faker::Lorem.sentences(opts[:count_of_data])
  dataset = DataSet.new(options[:keywords],raw_data)

  testdata = TestData.new(dataset)
  testdata.generate
end