Class: Thrust::Tasks::FocusedSpecs

Inherits:
Object
  • Object
show all
Defined in:
lib/thrust/tasks/focused_specs.rb

Constant Summary collapse

FOCUSED_METHODS =
%w[fit(@ fcontext(@ fdescribe(@]

Instance Method Summary collapse

Constructor Details

#initialize(out = $stdout, executor = Thrust::Executor.new) ⇒ FocusedSpecs

Returns a new instance of FocusedSpecs.



6
7
8
9
# File 'lib/thrust/tasks/focused_specs.rb', line 6

def initialize(out = $stdout, executor = Thrust::Executor.new)
  @out = out
  @executor = executor
end

Instance Method Details

#run(app_config) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/thrust/tasks/focused_specs.rb', line 11

def run(app_config)
  if app_config.spec_directories.empty?
    @out.puts 'Unable to find focused specs without `spec_directories` defined in thrust.yml.'.red
    exit 1
  end

  pattern = FOCUSED_METHODS.join("\\|")
  directories = app_config.spec_directories.map{ |sd| "\"#{sd}\"" }.join(' ')
  output = @executor.capture_output_from_system %Q[grep -l -r -e "\\(#{pattern}\\)" #{directories} | grep -v 'Frameworks' || true]

  @out.puts output

  output.split("\n")
end