Giter Site home page Giter Site logo

Comments (3)

pirj avatar pirj commented on September 3, 2024 1

Detecting and revering changes on a vast number of class objects in the object space, global variables, constants etc between each example is hard if even possible, error-prone and would have an insane overhead.

If you need isolation, use https://github.com/rspec/rspec-support/blob/8cbf7f9aecbefacd74da16ec2e713358ff72925b/lib/rspec/support/spec/in_sub_process.rb
Check https://github.com/search?q=org%3Arspec%20in_sub_process&type=code for usage examples.

from rspec-core.

francktrouillez avatar francktrouillez commented on September 3, 2024 1

Thanks for the quick answer! I was indeed expecting this, but wanted to make sure, in case I missed something.

Thanks!

from rspec-core.

JonRowe avatar JonRowe commented on September 3, 2024 1

This is an example of global state and we can't make any atttempt to reset this for you but I can suggest some approaches to help test it:

You can add a "reset" to this global state and call it between each spec in a hook, we actually do this ourselves in places.

You could also change how this state is encapsulated and instead of using multiple class variables you have a normal instance of a class which you test, but then have a single "class instance" of this class in reality, you can see an example of this with our "RSpec::World".

from rspec-core.

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.