title: Capistrano Checking for undefined variable in Task
body: <p>In Capistrano using the Multi-stage extension I have two environments: prod and testing.</p>
  
  <p>I need a few variables in testing.rb that are not needed in prod.rb and I want some of my tasks to be able to check if the variable is defined and use it if it is, but ignore it if it is not set.</p>
  
  <p>So, in testing.rb I would have something like:</p>
  
  <pre><code>set :foo, 'bar'
  </code></pre>
  
  <p>prod.rb wouldn't have any reference to :foo since it doesn't need it. In one of my tasks, I would like to do something like:</p>
  
  <pre><code>if defined?(foo)
    # do something with foo
  else
    # do something without foo
  end
  </code></pre>
  
  <p>But I keep getting the error:</p>
  
  <pre><code>undefined local variable or method 'foo'
  </code></pre>
  
  <p>Is there a way to test for undefined global variables in the task? Or do I have to do something like:</p>
  
  <pre><code>set :foo, ''
  </code></pre>
  
  <p>In all my environments that don't need the :foo variable?</p>