Module: Blueprints::Helper
- Included in:
- ActiveSupport::TestCase
- Defined in:
- lib/blueprints/helper.rb
Overview
A helper module that should be included in test framework. Adds methods build
and demolish
Instance Method Summary collapse
-
#build(*names) ⇒ Object
(also: #build_blueprint)
Builds one or more blueprints by their names.
-
#build!(*names) ⇒ Object
(also: #build_blueprint!)
Same as Blueprints::Helper#build except that you can use it to build same blueprint several times.
-
#build_attributes(name) ⇒ Hash
Returns attributes that are used to build blueprint.
-
#build_with(strategy, *names) ⇒ Object
Same as Blueprints::Helper#build except it also allows you to pass strategy to use (#build always uses default strategy).
-
#d(*args) ⇒ Blueprints::Dependency
(also: #blueprint_dependency)
Returns Blueprint::Dependency object that can be used to define dependencies on other blueprints.
-
#demolish(*names) ⇒ Object
(also: #blueprint_demolish)
Demolishes built blueprints (by default simply calls destroy method on result of blueprint, but can be customized).
Instance Method Details
#build(*names) ⇒ Object Also known as: build_blueprint
Builds one or more blueprints by their names. You can pass names as symbols or strings. You can also pass additional options hash which will be available by calling options
in blueprint block. Returns result of last blueprint block.
14 15 16 |
# File 'lib/blueprints/helper.rb', line 14 def build(*names) Namespace.root.build(names, self) end |
#build!(*names) ⇒ Object #build!(count, *names) ⇒ Array Also known as: build_blueprint!
Same as Blueprints::Helper#build except that you can use it to build same blueprint several times.
26 27 28 29 30 31 32 |
# File 'lib/blueprints/helper.rb', line 26 def build!(*names) if names.first.is_a?(Integer) (0...names.shift).collect { build! *names } else Namespace.root.build(names, self, :rebuild => true) end end |
#build_attributes(name) ⇒ Hash
Returns attributes that are used to build blueprint.
53 54 55 56 57 |
# File 'lib/blueprints/helper.rb', line 53 def build_attributes(name) blueprint = Namespace.root[name] blueprint.build_parents(self) blueprint.normalized_attributes(self) end |
#build_with(strategy, *names) ⇒ Object
Same as Blueprints::Helper#build except it also allows you to pass strategy to use (#build always uses default strategy).
38 39 40 |
# File 'lib/blueprints/helper.rb', line 38 def build_with(strategy, *names) Namespace.root.build(names, self, :strategy => strategy) end |
#d(*args) ⇒ Blueprints::Dependency Also known as: blueprint_dependency
Returns Blueprint::Dependency object that can be used to define dependencies on other blueprints.
66 67 68 |
# File 'lib/blueprints/helper.rb', line 66 def d(*args) Dependency.new(*args) end |
#demolish(*names) ⇒ Object Also known as: blueprint_demolish
Demolishes built blueprints (by default simply calls destroy method on result of blueprint, but can be customized).
74 75 76 |
# File 'lib/blueprints/helper.rb', line 74 def demolish(*names) names.each { |name| Namespace.root[name].demolish(self) } end |