Class: TestDots::RSpecListener

Inherits:
Object
  • Object
show all
Defined in:
lib/test_dots/rspec_listener.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRSpecListener

Returns a new instance of RSpecListener.



16
17
18
19
# File 'lib/test_dots/rspec_listener.rb', line 16

def initialize
  @results = []
  @dir = Pathname.new(Dir.pwd)
end

Class Method Details

.registerObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/test_dots/rspec_listener.rb', line 3

def self.register
  RSpec.configure do |config|
    methods = [
      :dump_summary,
      :example_passed,
      :example_pending,
      :example_failed,
      :close
    ]
    config.reporter.register_listener self.new, *methods
  end
end

Instance Method Details

#close(_) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/test_dots/rspec_listener.rb', line 21

def close(_)
  attributes = TestDots.send_report(
    framework: 'rspec',
    load_time: @load_time,
    run_time: @run_time,
    results: @results
  )
end

#dump_summary(summary_notification) ⇒ Object



30
31
32
33
# File 'lib/test_dots/rspec_listener.rb', line 30

def dump_summary(summary_notification)
  @load_time = summary_notification.load_time
  @run_time = summary_notification.duration
end

#example_failed(notification) ⇒ Object



43
44
45
# File 'lib/test_dots/rspec_listener.rb', line 43

def example_failed(notification)
  example_finished(notification)
end

#example_passed(notification) ⇒ Object



39
40
41
# File 'lib/test_dots/rspec_listener.rb', line 39

def example_passed(notification)
  example_finished(notification)
end

#example_pending(notification) ⇒ Object



35
36
37
# File 'lib/test_dots/rspec_listener.rb', line 35

def example_pending(notification)
  example_finished(notification)
end