Git Product home page Git Product logo

Comments (3)

alexandredosim avatar alexandredosim commented on May 27, 2024

Hello Msmevol.
When call command runs on the same environment than the example block, since it doesn't run in a subshell. This grants hello function access to p1 values defined within the same example/example group block. Furthermore, in general, mock techniques are intended to be used with functions (or classes/objects depending on the context), so I would expect p1 definition to be something like p1="world". You don't even need to define p1 with local as ShellSpec already isolates the examples and example groups one from the other.
In bash, when one define a local variable that have the same name as the global variable, it shadows the global variable. Thus the line echo p1 of the hello function refers to the local variable. In my experience, the local values are intended to not pollute the global environment of the script and to protect the variables used inside the function. This way, unless the value of the local variable is defined by the command args, it doesn't make sense to modify those values. If you feel that you must test different values of a local variable, maybe the variable need to be not local or there's an architectural flaw.
Best regards.

from shellspec.

Msmevol avatar Msmevol commented on May 27, 2024

from shellspec.

alexandredosim avatar alexandredosim commented on May 27, 2024

In Python, all variables are public from the start and is a lot easier to modify their values. There's some hackish ways to make then private thought.
If you feel your question is answered, please close the issue.

from shellspec.

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.