Using RSpec, constants inside describe a big no-no?

I just spent time trying to understand why my specifications went in isolation, but when testing the controller and the library together, some specifications were mysteriously unsuccessful. The culprit was the following:

In one spec:

describe SomeThing do
  CONSTANT_VALUE = "a value"

  # ... examples etc ...
end

And in another:

describe AnotherThing do
  CONSTANT_VALUE = "a different value"

  # ... the rest is history
end

The values ​​assigned to these constants flowed between my specifications and caused unexpected behavior. Should I use a block letto define constants, etc.? Or something else?

+3
source share
1 answer

Yes, the letanswer is here.

+4
source

All Articles