Class: RoxClient::RSpec::Formatter

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

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Formatter

Returns a new instance of Formatter.



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

def initialize output

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

  @groups = []
end

Instance Method Details

#close(notification) ⇒ Object



52
53
54
# File 'lib/rox-client-rspec/formatter.rb', line 52

def close notification
  @client.process @test_run
end

#example_failed(example_notification) ⇒ Object



42
43
44
# File 'lib/rox-client-rspec/formatter.rb', line 42

def example_failed example_notification
  add_result example_notification, false
end

#example_group_finished(group_notification) ⇒ Object



30
31
32
# File 'lib/rox-client-rspec/formatter.rb', line 30

def example_group_finished group_notification
  @groups.pop
end

#example_group_started(group_notification) ⇒ Object



26
27
28
# File 'lib/rox-client-rspec/formatter.rb', line 26

def example_group_started group_notification
  @groups << group_notification.group
end

#example_passed(example_notification) ⇒ Object



38
39
40
# File 'lib/rox-client-rspec/formatter.rb', line 38

def example_passed example_notification
  add_result example_notification, true
end

#example_started(example_notification) ⇒ Object



34
35
36
# File 'lib/rox-client-rspec/formatter.rb', line 34

def example_started example_notification
  @current_time = Time.now
end

#start(notification) ⇒ Object



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

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

#stop(notification) ⇒ Object



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

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