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