On Mon, May 25, 2009 at 1:51 AM, Sarah Allen <li...@ruby-forum.com> wrote: > David Chelimsky wrote: >> >> Foo::Bar.stub(:do_something) > > hmm. that's pretty close to where I started. > >> If you stub, for example, do_something on this module, but it turns >> out that do_something gets added to the module through some dynamic >> means *after the stub declaration*, the stub declaration will be >> overwritten and you'll get surprising results. This is not just true >> of globals - it's true of any methods that appear through the magic of >> metaprogramming. > > Ah, the joys of dynamic languages. After further looking at the code, I > see that the module 'require' is intentionally inside an if, so that it > will only get loaded as needed. If I explicitly require file containing > the module in the spec.rb file, then it works. I suppose the require in > the code I'm testing will only have an effect when it's not present in > the calling code. Still puzzled why I could call the module before > without getting a syntax error.
By "before" do you mean in an earlier version of your app or of rspec? Or do you mean within the app somewhere? > > Thanks so much for your help. > > Sarah > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users