Class: Blueprints::Configuration
- Inherits:
-
Object
- Object
- Blueprints::Configuration
- Defined in:
- lib/blueprints/configuration.rb
Overview
Contains configuration of blueprints. Instance of this is yielded in Blueprints.enable block.
Instance Attribute Summary collapse
-
#default_attributes ⇒ Object
Default attributes are used when blueprints has no name specified.
-
#filename ⇒ Object
Allows passing custom filename pattern in case blueprints are held in place other than spec/blueprint, test/blueprint, blueprint.
-
#prebuild ⇒ Object
Allows passing scenarios that should be prebuilt and available in all tests.
-
#root ⇒ Object
Allows passing custom root folder to use in case of non rails project.
-
#transactions ⇒ Object
By default blueprints runs each test in it’s own transaction.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
Initializes new Configuration object with default attributes.
Constructor Details
#initialize ⇒ Configuration
Initializes new Configuration object with default attributes. By defaults filename patterns are: blueprint.rb and blueprint/*.rb in spec, test and root directories. Also by default prebuildable blueprints list is empty, transactions are enabled and root is set to Rails.root or current directory.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/blueprints/configuration.rb', line 24 def initialize self.filename = [nil, "spec", "test"].map do |dir| ["blueprint"].map do |file| path = File.join([dir, file].compact) ["#{path}.rb", File.join(path, "*.rb")] end end.flatten @prebuild = [] @transactions = true @root = defined?(Rails) ? Rails.root : Pathname.pwd @default_attributes = [:name] end |
Instance Attribute Details
#default_attributes ⇒ Object
Default attributes are used when blueprints has no name specified.
19 20 21 |
# File 'lib/blueprints/configuration.rb', line 19 def default_attributes @default_attributes end |
#filename ⇒ Object
Allows passing custom filename pattern in case blueprints are held in place other than spec/blueprint, test/blueprint, blueprint.
11 12 13 |
# File 'lib/blueprints/configuration.rb', line 11 def filename @filename end |
#prebuild ⇒ Object
Allows passing scenarios that should be prebuilt and available in all tests. Works similarly to fixtures.
13 14 15 |
# File 'lib/blueprints/configuration.rb', line 13 def prebuild @prebuild end |
#root ⇒ Object
Allows passing custom root folder to use in case of non rails project. Defaults to Rails.root or current folder if Rails is not defined.
15 16 17 |
# File 'lib/blueprints/configuration.rb', line 15 def root @root end |
#transactions ⇒ Object
By default blueprints runs each test in it’s own transaction. This may sometimes be not desirable so this options allows to turn this off.
17 18 19 |
# File 'lib/blueprints/configuration.rb', line 17 def transactions @transactions end |