Class: Computering::Dsl::Spec

Inherits:
Text
  • Object
show all
Defined in:
lib/computering/dsl/spec.rb

Instance Attribute Summary

Attributes inherited from Text

#text

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Text

#[], #blank?, #buffer, from_text, #padding

Constructor Details

#initialize(name, text, &block) ⇒ Spec

Returns a new instance of Spec.



22
23
24
25
26
27
# File 'lib/computering/dsl/spec.rb', line 22

def initialize(name, text, &block)
  super text
  @name   = name
  @block  = block
  @buffer = "\n"
end

Class Method Details

.from_block(name, text, &block) ⇒ Object



18
19
20
# File 'lib/computering/dsl/spec.rb', line 18

def self.from_block(name, text, &block)
  Array(self.new name, text, &block)
end

Instance Method Details

#executeObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/computering/dsl/spec.rb', line 29

def execute
  describe @name, &@block

  output    = StringIO.new("")
  reporter  = Minitest::SummaryReporter.new(output)

  reporter.start

  Minitest::Runnable.runnables.each do |runnable|
    runnable.run reporter
  end

  reporter.report

  @buffer << output.string.strip
  Minitest::Test.reset
rescue
  @buffer << add_style($!.message, :error)
end