Module: Bacon
- Extended by:
- BetterOutput, SpecDoxOutput
- Defined in:
- lib/bacon/ext/em.rb,
lib/bacon.rb,
lib/bacon/version.rb,
lib/bacon/ext/http.rb,
lib/bacon/ext/mocha.rb,
lib/bacon/ext/no_gc.rb
Overview
This extension ensure that mocha expectations are considered as bacon tests. Amongst other thing it allows to have a test containing only mocha expectations.
Defined Under Namespace
Modules: ContextAssertions, DisableGC, EMSpec, HTTPHelpers, MochaRequirementsCounter, MochaSpec Classes: Context, Error
Constant Summary collapse
- Counter =
Hash.new(0)
- ErrorLog =
""
Hash.new { |_, name| raise NameError, "no such context: #{name.inspect}" }
- Backtraces =
true
- VERSION =
"1.6.2"
Class Attribute Summary collapse
-
.allow_focused_run ⇒ Object
(also: allow_focused_run?)
Returns the value of attribute allow_focused_run.
-
.focus_context_regexp ⇒ Object
Returns the value of attribute focus_context_regexp.
-
.focus_name_regexp ⇒ Object
Returns the value of attribute focus_name_regexp.
Class Method Summary collapse
- .backtrace_size ⇒ Object
- .backtrace_size=(n) ⇒ Object
- .freeze_time(t = Time.now) ⇒ Object
- .run_file(path) ⇒ Object
- .store_error(e, description) ⇒ Object
- .summary_on_exit ⇒ Object (also: summary_at_exit)
Methods included from BetterOutput
handle_requirement, handle_specification, handle_summary, spaces
Methods included from SpecDoxOutput
handle_requirement, handle_specification, handle_summary, spaces
Class Attribute Details
.allow_focused_run ⇒ Object Also known as: allow_focused_run?
Returns the value of attribute allow_focused_run.
37 38 39 |
# File 'lib/bacon.rb', line 37 def allow_focused_run @allow_focused_run end |
.focus_context_regexp ⇒ Object
Returns the value of attribute focus_context_regexp.
40 41 42 |
# File 'lib/bacon.rb', line 40 def focus_context_regexp @focus_context_regexp end |
.focus_name_regexp ⇒ Object
Returns the value of attribute focus_name_regexp.
40 41 42 |
# File 'lib/bacon.rb', line 40 def focus_name_regexp @focus_name_regexp end |
Class Method Details
.backtrace_size ⇒ Object
51 52 53 |
# File 'lib/bacon.rb', line 51 def self.backtrace_size @backtrace_size end |
.backtrace_size=(n) ⇒ Object
47 48 49 |
# File 'lib/bacon.rb', line 47 def self.backtrace_size=(n) @backtrace_size = n end |
.freeze_time(t = Time.now) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/bacon/ext/mocha.rb', line 11 def self.freeze_time(t = Time.now) Time.stubs(:now).returns(t) if block_given? begin yield ensure Time.unstub(:now) end end end |
.run_file(path) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/bacon.rb', line 55 def self.run_file(path) # run test load(path) # handle_summary Counter end |
.store_error(e, description) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/bacon.rb', line 87 def self.store_error(e, description) ErrorLog << "#{e.inspect}\n" backtrace = e.backtrace.find_all { |line| line !~ /guard|fsevent|thor|bacon/ } backtrace = backtrace[0, Bacon.backtrace_size] if Bacon.backtrace_size backtrace.each_with_index do |line, i| ErrorLog << " #{line}#{i==0 ? ": #@name - #{description}" : ""}\n" end ErrorLog << "\n" if e.kind_of? Error Counter[e.count_as] += 1 e.count_as.to_s.upcase [:failed] else Counter[:errors] += 1 [:error, e] end end |
.summary_on_exit ⇒ Object Also known as: summary_at_exit
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/bacon.rb', line 62 def self.summary_on_exit return if Counter[:installed_summary] > 0 interval = Hitimes::Interval.new interval.start() at_exit { handle_summary(interval.stop()) if $! raise $! elsif Counter[:errors] + Counter[:failed] > 0 exit 1 end } Counter[:installed_summary] += 1 end |