Sha256: 7da1333c39131c1a450ba940634af4c5636c5adf5e36aaead3250fa3b5791e09

Contents?: true

Size: 979 Bytes

Versions: 3

Compression:

Stored size: 979 Bytes

Contents

require File.dirname(__FILE__) + '/spec_helper.rb'
require 'fault_injection.rb'

include FaultInjection

describe Parser do
  it "should return FaultConditionLine on 'foo.rb:32'" do
	c = Parser.compile('foo.rb:32')
	c.instance_of?(FaultConditionLine).should be_true
	c.line.should be_eql(32)
	c.file.should be_eql('foo.rb')
  end

  it "can parse 'Class#method' format." do
	c = Parser.compile('Array#size')
	c.instance_of?(FaultConditionCall).should be_true
	c.stack_pattern.should be_eql([[:Array,:size]])
  end

  it "should raise NameError with invalid class" do
	Proc.new{
	  c = Parser.compile("00#size")
	}.should raise_error(ArgumentError)
  end

  it "should raise NameError with invalid method" do
	Proc.new{
	  c = Parser.compile("Array#3")
	}
  end

  it "can parse multiple method chain" do
	c = Parser.compile("Array#push > String#size")
	c.instance_of?(FaultConditionCall).should be_true

	c.stack_pattern.should be_eql([[:String,:size],[:Array,:push]])
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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