Class: Glimmer::Specification::Element::Fact

Inherits:
Glimmer::Specification::Element show all
Defined in:
lib/glimmer/specification/element/fact.rb

Class Attribute Summary collapse

Attributes inherited from Glimmer::Specification::Element

#args, #block, #keyword, #parent, #title

Instance Method Summary collapse

Methods inherited from Glimmer::Specification::Element

#ancestors, #children, #content, #content_added?, element_class, element_class_name, element_exist?, #executable?, #post_add_content, #post_initialize_child, #scenarios, #to_s, #verified?

Constructor Details

#initialize(parent, keyword, *args, &block) ⇒ Fact

Returns a new instance of Fact.



30
31
32
33
34
35
# File 'lib/glimmer/specification/element/fact.rb', line 30

def initialize(parent, keyword, *args, &block)
  @executable = true
  super
  source_code = PutsDebuggerer::SourceFile.new(@block.source_location.first).source(1, @block.source_location.last)
  @title = source_code.strip
end

Class Attribute Details

.fact_block_in_progressObject

Returns the value of attribute fact_block_in_progress.



27
28
29
# File 'lib/glimmer/specification/element/fact.rb', line 27

def fact_block_in_progress
  @fact_block_in_progress
end

Instance Method Details

#runObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/glimmer/specification/element/fact.rb', line 37

def run
  Fact.fact_block_in_progress = true
  @verified = @block.call
  Fact.fact_block_in_progress = false
  if @verified
    puts Colours::GREEN + "VERIFIED: #{to_s}"
  else
    puts Colours::RED + "NOT VERIFIED: #{to_s}"
  end
end