title: Defining and using constants inside Rspec's hooks
body: <p>I am kinda of new to Rspec and I am writing some test examples when a question came up.</p>
  
  <p>First, I was using global variables to define three constant values I was going to use in a lot of tests. For example:</p>
  
  <pre><code>$message = 'this is a test'
  </code></pre>
  
  <p>However, I notice that this global was being carried over to other test files and causing issues. Ok... decided then to avoid the globals as this can cause a lot of pain in the future in case my test file number grows.</p>
  
  <p>I then went for the let() block. Example:</p>
  
  <pre><code>let(:message) { 'this is a test' }
  </code></pre>
  
  <p>Now the problem was that this variable could not be used inside before and after hooks. Ok...</p>
  
  <p>My last try was using constants inside the contexts/describes, like this:</p>
  
  <pre><code>self::MESSAGE =  'this is a test'
  </code></pre>
  
  <p>However, just like let's this cannot be used inside the hooks as they are not either classes or modules.</p>
  
  <p>So, I am stuck ...</p>
  
  <p>How do you guys deal with that? Will I need to create instance variables for that? Is that any other alternative I can use?</p>
  
  <p>Thank you very much.</p>