Hi, I'm trying to stub File.open and whenever I do, rspec blows up with the following error message (undefined method `add' for nil:NilClass), which seems to happen because method __add in class Proxy is calling #add on global $rspec_mocks, which in turn is nil.
Can someone explain what I'm doing wrong, as I can't seem to stub anything out! Here's my code: class Foo def Foo.open( name, mode ) return name end end describe Something, 'blah blah' do class FooDouble #:nodoc: attr_reader :data def initialize @data = [] end def method_missing( name, *args ) puts "ignoring call to #{name} with args [#{args.each |arg| arg.inspect}]" end def <<(raw_data) @data.push raw_data end end before :all do Foo.stub!( :open ).and_return( FooDouble.new ) #have also tried and_return { FooDouble.new } end ... end _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users