require File.dirname(__FILE__) + '/spec_helper.rb' require 'fault_injection.rb' include FaultInjection class Foo def foo end end class Bar def bar f = Foo.new f.foo end end describe FaultConditionCall do it "matches method calling backtrace" do c = FaultConditionCall.new c.stack_pattern = [[:Array,:each]] c.should_raise_on([[:Array,:each]]).should be_true c.should_raise_on([[:Hash,:keys], [:Array,:each]]).should be_true c.should_raise_on([[:Integer,:to_f]]).should_not be_true c.stack_pattern = [ [:Array,:each], # callee first [:Hash, :keys], [:Integer, :to_s] ] c.should_raise_on([[:Array,:each]]).should_not be_true c.should_raise_on(c.stack_pattern.reverse).should be_true bt = [ [:String,:size], # caller first [:Integer, :to_s], [:Hash, :keys], [:Array,:each] ] c.should_raise_on(bt).should be_true end end