class Fix::Test
Wraps the target of the specs document.
@api private
Attributes
configuration[R]
@!attribute [r] configuration
@return [Hash] The settings.
results[R]
@!attribute [r] results
@return [Array] The results.
total_time[R]
@!attribute [r] total_time
@return [Float] The total time.
Public Class Methods
new(front_object, verbose: true, color: true, **options, &specs)
click to toggle source
Initialize the test class.
@param front_object [BasicObject] The front object of the test. @param options [Hash] Some options. @param specs [Proc] The specs to test against the object.
# File lib/fix/test.rb, line 14 def initialize(front_object, verbose: true, color: true, **options, &specs) @configuration = options.merge( verbose: verbose, color: color ) start_time = ::Time.now g = On.new(front_object, [], [], {}, @configuration) g.instance_eval(&specs) @results = g.results @total_time = ::Time.now - start_time end
Public Instance Methods
fail?()
click to toggle source
@return [Boolean] Return false if the test fail.
# File lib/fix/test.rb, line 71 def fail? !pass? end
pass?()
click to toggle source
The state of the test.
@return [Boolean] Return true if the test pass.
# File lib/fix/test.rb, line 66 def pass? results.all?(&:result?) end
report()
click to toggle source
The report of the test.
@return [Report] The report of the test.
# File lib/fix/test.rb, line 59 def report Report.new(self) end
statistics()
click to toggle source
Some statistics.
@return [Hash] Some statistics.
# File lib/fix/test.rb, line 47 def statistics { pass_percent: pass_percent, total_infos: results.count { |r| r.to_sym.equal?(:info) }, total_failures: results.count { |r| r.to_sym.equal?(:failure) }, total_errors: results.count { |r| r.to_sym.equal?(:error) } } end
Private Instance Methods
pass_percent()
click to toggle source
@private
@return [Fixnum] Return the percentage of passing specs.
# File lib/fix/test.rb, line 80 def pass_percent return 100 if results.empty? (results.count(&:result?) / results.length.to_f * 100).round end