Class: Opal::RSpec::Locator

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

Constant Summary collapse

DEFAULT_PATTERN =
'spec-opal/**/*_spec{.js,}.{rb,opal}'
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.



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

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.



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

def default_path
  @default_path
end

#spec_exclude_patternObject

Returns the value of attribute spec_exclude_pattern.



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

def spec_exclude_pattern
  @spec_exclude_pattern
end

#spec_filesObject

Returns the value of attribute spec_files.



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

def spec_files
  @spec_files
end

#spec_patternObject

Returns the value of attribute spec_pattern.



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

def spec_pattern
  @spec_pattern
end

Instance Method Details

#determine_rootObject



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

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

#get_opal_spec_requiresObject



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

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



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

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