Class: Guard::RSpec::Inspectors::FocusedInspector

Inherits:
BaseInspector
  • Object
show all
Defined in:
lib/guard/rspec/inspectors/focused_inspector.rb

Overview

Inspector that focuses on set of paths if any of them is failing. Returns only that set of paths on all future calls to #paths until they all pass

Instance Attribute Summary collapse

Attributes inherited from BaseInspector

#options, #spec_paths

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FocusedInspector

Returns a new instance of FocusedInspector.



12
13
14
15
# File 'lib/guard/rspec/inspectors/focused_inspector.rb', line 12

def initialize(options = {})
  super
  @focused_locations = []
end

Instance Attribute Details

#focused_locationsObject

Returns the value of attribute focused_locations.



10
11
12
# File 'lib/guard/rspec/inspectors/focused_inspector.rb', line 10

def focused_locations
  @focused_locations
end

Instance Method Details

#failed(locations) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/guard/rspec/inspectors/focused_inspector.rb', line 25

def failed(locations)
  if locations.empty?
    @focused_locations = []
  elsif focused_locations.empty?
    @focused_locations = locations
  end
end

#paths(paths) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/guard/rspec/inspectors/focused_inspector.rb', line 17

def paths(paths)
  if focused_locations.any?
    focused_locations
  else
    _clean(paths)
  end
end

#reloadObject



33
34
35
# File 'lib/guard/rspec/inspectors/focused_inspector.rb', line 33

def reload
  @focused_locations = []
end