Sha256: 41b38be4b54b0e6e76ed996af087f2c8b45491a020f36aaf7e118986dd4222ca

Contents?: true

Size: 905 Bytes

Versions: 3

Compression:

Stored size: 905 Bytes

Contents

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
faultinjection-0.0.1 spec/fault_condition_call_spec.rb
faultinjection-0.0.2 spec/fault_condition_call_spec.rb
faultinjection-0.0.3 spec/fault_condition_call_spec.rb