From: Tim Pease Date: 2009-05-20T03:25:38+09:00 Subject: Re: Mock a %x call On Tue, May 19, 2009 at 8:07 AM, Fernando Perez wrote: > Hi, > > Is it possible to mock such method call? > > I tried: Kernel.expects(:'%x').returns('whatever'). > > But I get the following error: > SyntaxError: compile error > /usr/local/ruby1.8.7/lib/ruby/gems/1.8/gems/mocha-0.9.5/lib/mocha/class_method.rb:40: > syntax error, unexpected '(', expecting '\n' or ';' > def %x(*args, &block); mocha.method_missing(:%x, *args, &block); end The various % constructs in ruby are handled by the parser and, therefore, cannot be mocked using method stubbing employed by mocha, rspec mocks, et al. Blessings, TwP