Class: Blueprints::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/blueprints/configuration.rb

Overview

Contains configuration of blueprints. Instance of this is yielded in Blueprints.enable block.

Examples:

Configuring through Blueprints.enable block

Blueprints.enable do |config|
  config.prebuild = :user, :profile
end

Configuring directly

Blueprints.config.transactions = false

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_attributesObject

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

#filenameObject

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

#prebuildObject

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

#rootObject

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

#transactionsObject

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