Class: Nitrous::TestContext

Inherits:
Object
  • Object
show all
Defined in:
lib/nitrous/test_context.rb

Direct Known Subclasses

CommandLineTestContext

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(test_count) ⇒ TestContext

Returns a new instance of TestContext.



16
17
18
19
# File 'lib/nitrous/test_context.rb', line 16

def initialize(test_count)
  @start_time = Time.now
  @total, @failures, @test, @skip = test_count, 0, 0, 0
end

Class Method Details

.create(test_count) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/nitrous/test_context.rb', line 8

def self.create(test_count)
  if gui?
    TestContext.new(test_count)
  else
    CommandLineTestContext.new(test_count)
  end
end

.gui?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/nitrous/test_context.rb', line 4

def self.gui?
  !!ENV["TM_MODE"] || !!ENV["VIMRUNTIME"]
end

Instance Method Details

#exit_statusObject



36
37
38
# File 'lib/nitrous/test_context.rb', line 36

def exit_status
  @failures > 0 ? 1 : 0
end

#failed(exception) ⇒ Object



28
29
30
# File 'lib/nitrous/test_context.rb', line 28

def failed(exception)
  @failures += 1
end

#finishObject



32
33
34
# File 'lib/nitrous/test_context.rb', line 32

def finish
  puts summary_with_benchmark
end

#ran_test(test, result) ⇒ Object



21
22
23
24
25
26
# File 'lib/nitrous/test_context.rb', line 21

def ran_test(test, result)
  @test += 1
  @skip += 1 if test.skip?
  puts result
  puts result.errors.map(&:test_output).join("\n\n") + "\n" unless result.errors.empty?
end

#summaryObject



40
41
42
# File 'lib/nitrous/test_context.rb', line 40

def summary
  "Test #{@test} of #{@total} -- #{@failures} failure#{@failures == 1 ? '' : 's'} -- #{@skip} skipped"
end

#summary_with_benchmarkObject



44
45
46
# File 'lib/nitrous/test_context.rb', line 44

def summary_with_benchmark
  summary + " -- #{Time.now - @start_time} seconds"
end