Class: WTT::RSpec::Indexer

Inherits:
RSpec::Core::Formatters::BaseFormatter
  • Object
show all
Defined in:
lib/wtt/rspec/indexer.rb

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Indexer

Returns a new instance of Indexer.



20
21
22
23
24
25
26
27
# File 'lib/wtt/rspec/indexer.rb', line 20

def initialize(output)
  super
  @tests = []
  ENV['WTT_INDEXING'] ||= '1'
  @repo = Rugged::Repository.discover(Dir.pwd)
  @storage = WTT::Core::Storage.new(@repo)
  @mapping = WTT::Core::Mapper.new(@storage)
end

Instance Method Details

#close(_example) ⇒ Object



41
42
43
44
45
# File 'lib/wtt/rspec/indexer.rb', line 41

def close(_example)
  meta = WTT::Core::MetaData.new(@storage)
  meta['specs'] = @tests
  meta.write!
end

#example_failed(notification) ⇒ Object



33
34
35
# File 'lib/wtt/rspec/indexer.rb', line 33

def example_failed(notification)
  record_example notification.example
end

#example_passed(notification) ⇒ Object



29
30
31
# File 'lib/wtt/rspec/indexer.rb', line 29

def example_passed(notification)
  record_example notification.example
end

#record_example(example) ⇒ Object



37
38
39
# File 'lib/wtt/rspec/indexer.rb', line 37

def record_example(example)
  @tests << example.id
end