class Storexplore::Testing::DummyStoreGenerator
Dummy store generation one liner. Forwards chains of method calls to a collections of Storexplore::Testing::DummyStore
instances.
This file can be required on its own
Public Class Methods
new(pages, count = 1)
click to toggle source
-
pages : collection of
Storexplore::Testing::DummyStore
instances to which calls will be forwarded -
count : number of children (categories or items) that will be added with every generation call
# File lib/storexplore/testing/dummy_store_generator.rb, line 37 def initialize(pages, count = 1) @pages = pages @count = count end
Public Instance Methods
and(count)
click to toggle source
Changes the number of generated children
# File lib/storexplore/testing/dummy_store_generator.rb, line 43 def and(count) @count = count self end
attributes(options = {})
click to toggle source
generates attributes for all @pages. Explicit attributes can be specified
# File lib/storexplore/testing/dummy_store_generator.rb, line 64 def attributes(options = {}) @pages.map do |page| attributes = DummyData.attributes(page.name, options) page.attributes(HashUtils.without(attributes, [:name])) end end
categories()
click to toggle source
Generates @count categories on all @pages
# File lib/storexplore/testing/dummy_store_generator.rb, line 49 def categories dispatch(:category) end
Also aliased as: category
items()
click to toggle source
Generates @count items with attributes on all @pages
# File lib/storexplore/testing/dummy_store_generator.rb, line 56 def items dispatch(:item).attributes end
Also aliased as: item
Private Instance Methods
dispatch(message)
click to toggle source
# File lib/storexplore/testing/dummy_store_generator.rb, line 73 def dispatch(message) sub_pages = @pages.map do |page| @count.times.map do page.send(message, DummyData.name(message)) end end DummyStoreGenerator.new(sub_pages.flatten) end