GithubHelp home page GithubHelp logo

Mock Kernel#require and #load about fakefs HOT 6 CLOSED

fakefs avatar fakefs commented on July 20, 2024
Mock Kernel#require and #load

from fakefs.

Comments (6)

jmhodges avatar jmhodges commented on July 20, 2024

I can't think of a use case for this. Do you have one?

from fakefs.

nakajima avatar nakajima commented on July 20, 2024

It may be useful, but maybe not for this library. It'd be a nice to have a mechanism for faking dependencies for libraries that manage dependencies.

from fakefs.

 avatar commented on July 20, 2024

I imagine something like this: http://gist.github.com/297952
The #require mock is only activated if required (= needed).

The usecase i encountered yesterday is a class loading modules by configuration. I could still use Object.eval, but then I would align my codebase to my testing code. http://github.com/lgierth/pakada/blob/master/lib/pakada.rb#L43

I'll see if I can send a patch/pull request during the next days.

Best regards,
Lars

from fakefs.

 avatar commented on July 20, 2024

Voila: http://github.com/lgierth/fakefs/tree/topic/fake-require

You have to explicitly say that you want to fake Kernel#require, either by loading it before FakeFS.activate! or by loading it and calling FakeFS::Require.activate!.

Best regards,
Lars

from fakefs.

 avatar commented on July 20, 2024

Any thoughts on this?

I think I am now nearly completely faking #require, including the possibility to require files outside of FakeFS that reside in gems and to apply the faked #require also to #autoload.

Anyway the tests aren't complete and there's no documentation, I'll see if I can manage this during the next days.

Best regards,
Lars

from fakefs.

 avatar commented on July 20, 2024

I released this as fakefs-require some weeks ago.
http://rubygems.org/gems/fakefs-require

from fakefs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.