Class: Opal::RSpec::Locator

Inherits:
Object
  • Object
show all
Includes:
RSpec::Core::RubyProject
Defined in:
lib/opal/rspec/locator.rb

Constant Summary collapse

DEFAULT_GLOB =
'**{,/*/**}/*_spec{.js,}.{rb,opal}'
DEFAULT_PATTERN =
"spec-opal/#{DEFAULT_GLOB}"
DEFAULT_DEFAULT_PATH =
'spec-opal'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern: nil, exclude_pattern: nil, files: nil, default_path: nil) ⇒ Locator

Returns a new instance of Locator.



18
19
20
21
22
23
# File 'lib/opal/rspec/locator.rb', line 18

def initialize(pattern: nil, exclude_pattern: nil, files: nil, default_path: nil)
  @spec_pattern         = pattern || DEFAULT_PATTERN
  @spec_exclude_pattern = exclude_pattern
  @spec_files           = files
  @default_path         = default_path || DEFAULT_DEFAULT_PATH
end

Instance Attribute Details

#default_pathObject

Returns the value of attribute default_path.



16
17
18
# File 'lib/opal/rspec/locator.rb', line 16

def default_path
  @default_path
end

#spec_exclude_patternObject

Returns the value of attribute spec_exclude_pattern.



16
17
18
# File 'lib/opal/rspec/locator.rb', line 16

def spec_exclude_pattern
  @spec_exclude_pattern
end

#spec_filesObject

Returns the value of attribute spec_files.



16
17
18
# File 'lib/opal/rspec/locator.rb', line 16

def spec_files
  @spec_files
end

#spec_patternObject

Returns the value of attribute spec_pattern.



16
17
18
# File 'lib/opal/rspec/locator.rb', line 16

def spec_pattern
  @spec_pattern
end

Instance Method Details

#determine_rootObject



25
26
27
# File 'lib/opal/rspec/locator.rb', line 25

def determine_root
  find_first_parent_containing(@default_path) || '.'
end

#get_opal_spec_requiresObject



33
34
35
36
# File 'lib/opal/rspec/locator.rb', line 33

def get_opal_spec_requires
  files = @spec_files || FileList[*@spec_pattern].exclude(*@spec_exclude_pattern)
  files.uniq.map { |file| File.expand_path file }
end

#get_spec_load_pathsObject



29
30
31
# File 'lib/opal/rspec/locator.rb', line 29

def get_spec_load_paths
  [@default_path].map { |dir| File.join(root, dir) }
end