Class: Storexplore::Testing::DummyStoreGenerator
- Inherits:
-
Object
- Object
- Storexplore::Testing::DummyStoreGenerator
- Defined in:
- lib/storexplore/testing/dummy_store_generator.rb
Overview
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
Instance Method Summary collapse
-
#and(count) ⇒ Object
Changes the number of generated children.
-
#attributes(options = {}) ⇒ Object
generates attributes for all @pages.
-
#categories ⇒ Object
(also: #category)
Generates @count categories on all @pages.
-
#initialize(pages, count = 1) ⇒ DummyStoreGenerator
constructor
-
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.
-
-
#items ⇒ Object
(also: #item)
Generates @count items with attributes on all @pages.
Constructor Details
#initialize(pages, count = 1) ⇒ DummyStoreGenerator
-
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
38 39 40 41 |
# File 'lib/storexplore/testing/dummy_store_generator.rb', line 38 def initialize(pages, count = 1) @pages = pages @count = count end |
Instance Method Details
#and(count) ⇒ Object
Changes the number of generated children
44 45 46 47 |
# File 'lib/storexplore/testing/dummy_store_generator.rb', line 44 def and(count) @count = count self end |
#attributes(options = {}) ⇒ Object
generates attributes for all @pages. Explicit attributes can be specified
65 66 67 68 69 70 |
# File 'lib/storexplore/testing/dummy_store_generator.rb', line 65 def attributes( = {}) @pages.map do |page| attributes = DummyData.attributes(page.name, ) page.attributes(HashUtils.without(attributes, [:name])) end end |
#categories ⇒ Object Also known as: category
Generates @count categories on all @pages
50 51 52 |
# File 'lib/storexplore/testing/dummy_store_generator.rb', line 50 def categories dispatch(:category) end |
#items ⇒ Object Also known as: item
Generates @count items with attributes on all @pages
57 58 59 |
# File 'lib/storexplore/testing/dummy_store_generator.rb', line 57 def items dispatch(:item).attributes end |