Module: Glimmer::Specification::Ext
- Defined in:
- lib/glimmer/specification/ext.rb
Class Attribute Summary collapse
-
.log_failure_of_method_in_progress ⇒ Object
(also: log_failure_of_method_in_progress?)
Returns the value of attribute log_failure_of_method_in_progress.
Class Method Summary collapse
Class Attribute Details
.log_failure_of_method_in_progress ⇒ Object Also known as: log_failure_of_method_in_progress?
Returns the value of attribute log_failure_of_method_in_progress.
28 29 30 |
# File 'lib/glimmer/specification/ext.rb', line 28 def log_failure_of_method_in_progress @log_failure_of_method_in_progress end |
Class Method Details
.log_failure_of_method(klass, method_name, method_alias = nil, &output_formatter) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/glimmer/specification/ext.rb', line 31 def log_failure_of_method(klass, method_name, method_alias = nil, &output_formatter) klass.class_eval do method_alias ||= "without_glimmer_#{method_name}" method_alias = "#{name.split('::').last.underscore}_#{method_alias}" alias_method method_alias, method_name define_method(method_name) do |*args| logging = false logging = Ext.log_failure_of_method_in_progress = true if !Ext.log_failure_of_method_in_progress? send(method_alias, *args).tap do |result| if logging output = output_formatter&.call(self, method_name, args) output ||= "#{self.inspect}.#{method_name}#{"(#{args.map(&:inspect).join(',')})" unless args.array_without_glimmer_empty?}" puts Colours::RED + "FAILED: #{output}" if Glimmer::Specification::Element::Fact.fact_block_in_progress && !result Ext.log_failure_of_method_in_progress = false end end end end end |