agaskar.com

Jan 26 2010

Fun (and evil) tricks with rspec

      original_glob = Dir.method(:glob)
      Dir.stub!(:glob).and_return do |glob_string|
        if glob_string =~ /public/
          glob_string
        else
          original_glob.call(glob_string)
        end
      end
Of course, you shouldn’t do this because return blocks on stubs (calculated return blocks) are evil. Still fun, though.

Comments (View)
Page 1 of 1
blog comments powered by Disqus