Class: Quickdraw::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/quickdraw/runner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tests = nil) ⇒ Runner

Returns a new instance of Runner.



18
19
20
21
22
23
# File 'lib/quickdraw/runner.rb', line 18

def initialize(tests = nil)
	@tests = tests

	@successes = []
	@failures = []
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



25
26
27
# File 'lib/quickdraw/runner.rb', line 25

def duration
  @duration
end

#failuresObject (readonly)

Returns the value of attribute failures.



25
26
27
# File 'lib/quickdraw/runner.rb', line 25

def failures
  @failures
end

#successesObject (readonly)

Returns the value of attribute successes.



25
26
27
# File 'lib/quickdraw/runner.rb', line 25

def successes
  @successes
end

Class Method Details

.call(queue) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/quickdraw/runner.rb', line 4

def self.call(queue)
	tests = []

	queue.drain do |f|
		tests << [f, Class.new(Quickdraw::Context) do
			class_eval(
				File.read(f), f, 1
			)
		end]
	end

	new(tests).tap(&:call)
end

Instance Method Details

#callObject



27
28
29
30
31
# File 'lib/quickdraw/runner.rb', line 27

def call
	@duration = Quickdraw::Timer.time do
		@tests.each { |(f, t)| t.run(self, [f]) }
	end
end

#failure!(path, &message) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/quickdraw/runner.rb', line 40

def failure!(path, &message)
	location = caller_locations.drop_while { |l| !l.path.include?(".test.rb") }

	@failures << [message, location, path]

	Kernel.print "🔴 "
	# ::Kernel.print "\e[31m⚬\e[0m"
end

#success!(name) ⇒ Object



33
34
35
36
37
38
# File 'lib/quickdraw/runner.rb', line 33

def success!(name)
	@successes << [name]

	Kernel.print "🟢 "
	# ::Kernel.print "\e[32m⚬\e[0m"
end