Class: RoxClient::RSpec::Formatter

Inherits:
RSpec::Core::Formatters::BaseFormatter
  • Object
show all
Defined in:
lib/rox-client-rspec/formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Formatter



9
10
11
12
13
14
15
16
17
# File 'lib/rox-client-rspec/formatter.rb', line 9

def initialize *args
  super *args

  config = RoxClient::RSpec.config
  @client = Client.new config.server, config.client_options
  @test_run = TestRun.new config.project

  @groups = []
end

Instance Method Details

#dump_summary(duration, example_count, failure_count, pending_count) ⇒ Object



50
51
52
# File 'lib/rox-client-rspec/formatter.rb', line 50

def dump_summary duration, example_count, failure_count, pending_count
  @client.process @test_run
end

#example_failed(example) ⇒ Object



40
41
42
# File 'lib/rox-client-rspec/formatter.rb', line 40

def example_failed example
  add_result example, false
end

#example_group_finished(group) ⇒ Object



28
29
30
# File 'lib/rox-client-rspec/formatter.rb', line 28

def example_group_finished group
  @groups.pop
end

#example_group_started(group) ⇒ Object



24
25
26
# File 'lib/rox-client-rspec/formatter.rb', line 24

def example_group_started group
  @groups << group
end

#example_passed(example) ⇒ Object



36
37
38
# File 'lib/rox-client-rspec/formatter.rb', line 36

def example_passed example
  add_result example, true
end

#example_started(example) ⇒ Object



32
33
34
# File 'lib/rox-client-rspec/formatter.rb', line 32

def example_started example
  @current_time = Time.now
end

#start(example_count) ⇒ Object



19
20
21
22
# File 'lib/rox-client-rspec/formatter.rb', line 19

def start example_count
  # TODO: measure milliseconds
  @start_time = Time.now
end

#stopObject



44
45
46
47
48
# File 'lib/rox-client-rspec/formatter.rb', line 44

def stop
  end_time = Time.now
  @test_run.end_time = end_time.to_i * 1000
  @test_run.duration = ((end_time - @start_time) * 1000).round
end