module Declare
Constants
- CallerEntry
- ScopeSummary
- VERSION
Attributes
failures[R]
Public Class Methods
auto_run()
click to toggle source
# File lib/declare/singleton_class.rb, line 19 def auto_run at_exit do $! || report end end
declared!()
click to toggle source
# File lib/declare/singleton_class.rb, line 30 def declared! @declare_counter += 1 end
describe(&block)
click to toggle source
# File lib/declare/singleton_class.rb, line 15 def describe(&block) BasicScope.new.instance_exec(&block) end
failure!(report)
click to toggle source
# File lib/declare/singleton_class.rb, line 42 def failure!(report) @failures[@scope_summaries.last] ||= [] @failures[@scope_summaries.last] << report end
failure_count()
click to toggle source
# File lib/declare/singleton_class.rb, line 47 def failure_count @failures.values.flatten.size end
new_scope(target, &block)
click to toggle source
@return [AssertionsScope]
# File lib/declare/singleton_class.rb, line 26 def new_scope(target, &block) AssertionsScope.new(target).instance_exec(target, &block) end
pass!()
click to toggle source
# File lib/declare/singleton_class.rb, line 38 def pass! @pass_counter += 1 end
report()
click to toggle source
# File lib/declare/singleton_class.rb, line 51 def report unless @failures.empty? report_detail puts '-' * 78 end failure_count = failure_count() puts "#{@scope_summaries.length} scopes, #{@declare_counter} assertions, #{failure_count} failures" exit(failure_count) end
scope!(target, caller_entry)
click to toggle source
# File lib/declare/singleton_class.rb, line 34 def scope!(target, caller_entry) @scope_summaries << ScopeSummary.new(target: target, caller_entry: caller_entry, nesting_level: caller_entry.block_level) end
Private Class Methods
report_detail()
click to toggle source
# File lib/declare/singleton_class.rb, line 65 def report_detail top_header = 'Detail testing report' puts top_header puts '=' * top_header.length, nil @failures.each_pair do |scope, lines| header = ( case scope.nesting_level when 0 obj_header = "#{scope.target.inspect} [#{scope.caller_entry.file_name}:#{scope.caller_entry.line_number}]" "#{obj_header}\n#{'-' * obj_header.length}" else "###{'#' * scope.nesting_level} #{scope.target.inspect} ###{'#' * scope.nesting_level} [#{scope.caller_entry.file_name}:#{scope.caller_entry.line_number}]" end ) puts header, nil puts(lines.map { |l| "* #{l}" }) end end
Public Instance Methods
to_s()
click to toggle source
@return [String]
# File lib/declare/callerentry.rb, line 29 def to_s "#{file_name}:#{line_number}" end