Skip to content

Instantly share code, notes, and snippets.

@banister
Created January 17, 2012 03:59
Show Gist options
  • Save banister/1624565 to your computer and use it in GitHub Desktop.
Save banister/1624565 to your computer and use it in GitHub Desktop.
intercepting test errors in bacon
crow:play john$ bacon bacon_intercept.rb
/Users/john/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.8pre4/lib/pry/pry_class.rb:207:
alpha
- should be empty
Frame number: 0/16
Frame type: method
From: /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/bacon-1.1.0/lib/bacon.rb @ line 331 in Should#satisfy:
326: end
327:
328: r = yield(@object, *args)
329: if Bacon::Counter[:depth] > 0
330: Bacon::Counter[:requirements] += 1
=>331: raise Bacon::Error.new(:failed, description) unless @negated ^ r
332: end
333: @negated ^ r ? r : false
334: end
335:
336: def method_missing(name, *args, &block)
[1] (pry) unknown: 0> up
Frame number: 1/16
Frame type: method
From: /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/bacon-1.1.0/lib/bacon.rb @ line 343 in Should#method_missing:
338:
339: desc = @negated ? "not " : ""
340: desc << @object.inspect << "." << name.to_s
341: desc << "(" << args.map{|x|x.inspect}.join(", ") << ") failed"
342:
=>343: satisfy(desc) { |x| x.__send__(name, *args, &block) }
344: end
345:
346: def equal(value) self == value end
347: def match(value) self =~ value end
348: def identical_to(value) self.equal? value end
[2] (pry) unknown: 0> up
Frame number: 2/16
Frame type: block
From: bacon_intercept.rb @ line 13:
8:
9: Pry.config.hooks.add_hook(:before_session, :blah) { EE.intercept { false } }
10:
11: describe "alpha" do
12: it 'should be empty' do
=> 13: [1].empty?.should == true
14: [2].empty?.should == false
15: end
16: end
[3] (pry) #<Bacon::Context>: 0> continue-exception
1 specifications (4 requirements), 0 failures, 0 errors
crow:play john$
require 'bacon'
require 'pry-exception_explorer'
EE.enabled = true
EE.intercept(Bacon::Error)
Pry.config.hooks.add_hook(:before_session, :blah) { EE.intercept { false } }
describe "alpha" do
it 'should be empty' do
[1].empty?.should == true
[2].empty?.should == false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment