Class: Teaspoon::Suite

Inherits:
Object
  • Object
show all
Defined in:
lib/teaspoon/suite.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Suite

Returns a new instance of Suite.



20
21
22
23
24
25
# File 'lib/teaspoon/suite.rb', line 20

def initialize(options = {})
  @options = options
  @name = (@options[:suite] || :default).to_s
  @config = suite_configuration
  @env = Rails.application.assets
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



16
17
18
# File 'lib/teaspoon/suite.rb', line 16

def config
  @config
end

#nameObject

Returns the value of attribute name.



16
17
18
# File 'lib/teaspoon/suite.rb', line 16

def name
  @name
end

Class Method Details

.allObject



4
5
6
# File 'lib/teaspoon/suite.rb', line 4

def self.all
  @all ||= Teaspoon.configuration.suite_configs.keys.map { |suite| Teaspoon::Suite.new(suite: suite) }
end

.resolve_spec_for(file) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/teaspoon/suite.rb', line 8

def self.resolve_spec_for(file)
  all.each do |suite|
    spec = suite.include_spec_for?(file)
    return {suite: suite.name, path: spec} if spec
  end
  false
end

Instance Method Details

#include_spec?(file) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/teaspoon/suite.rb', line 37

def include_spec?(file)
  glob.include?(file)
end

#include_spec_for?(file) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
44
45
46
# File 'lib/teaspoon/suite.rb', line 41

def include_spec_for?(file)
  return file if glob.include?(file)
  paths = glob.select { |path| path.include?(file)  }
  return paths unless paths.empty?
  false
end

#spec_assets(include_helper = true) ⇒ Object



31
32
33
34
35
# File 'lib/teaspoon/suite.rb', line 31

def spec_assets(include_helper = true)
  assets = specs
  assets.unshift(helper) if include_helper && helper
  asset_tree(assets)
end

#spec_filesObject



27
28
29
# File 'lib/teaspoon/suite.rb', line 27

def spec_files
  glob.map { |file| {path: file, name: asset_from_file(file)} }
end