title: Error when run cucumber with dry run option
body: <p>I'm trying to improve the speed of running tests by opening and closing the browser only once.</p>
  
  <p><a href="http://watirmelon.com/2012/04/01/five-page-object-anti-patterns/" rel="nofollow">http://watirmelon.com/2012/04/01/five-page-object-anti-patterns/</a></p>
  
  <p>I have the following in hooks.rb</p>
  
  <pre><code>browser = Watir::Browser.new ENV['BROWSER'].to_sym
  
  Before do
    @browser = browser
  end
  
  After do |scenario|
    @browser.cookies.clear
  end
  
  at_exit do
    browser.close
  end
  </code></pre>
  
  <p>It greatly boosts up the speed of test suite running. But I also need some statistics in json file from my custom formatter without running tests: </p>
  
  <pre><code>cucumber -t @test -d -f Cucumber::Formatter::MyCustomFormatter &gt; result.json
  </code></pre>
  
  <p>The problem is that cucumber catches error with <code>-d</code> option:</p>
  
  <pre><code>uninitialized constant Watir (NameError)
  /home/user/work/repository/features/support/hooks.rb:7:in `&lt;top (required)&gt;'
  /home/user/.rvm/gems/ruby-2.0.0-p247/gems/cucumber-1.3.5/lib/cucumber/rb_support/rb_language.rb:122:in `load'
  /home/user/.rvm/gems/ruby-2.0.0-p247/gems/cucumber-1.3.5/lib/cucumber/rb_support/rb_language.rb:122:in `load_code_file'
  /home/user/.rvm/gems/ruby-2.0.0-p247/gems/cucumber-1.3.5/lib/cucumber/runtime/support_code.rb:180:in `load_file'
  /home/user/.rvm/gems/ruby-2.0.0-p247/gems/cucumber-1.3.5/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
  /home/user/.rvm/gems/ruby-2.0.0-p247/gems/cucumber-1.3.5/lib/cucumber/runtime/support_code.rb:82:in `each'
  /home/user/.rvm/gems/ruby-2.0.0-p247/gems/cucumber-1.3.5/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
  /home/user/.rvm/gems/ruby-2.0.0-p247/gems/cucumber-1.3.5/lib/cucumber/runtime.rb:183:in `load_step_definitions'
  /home/user/.rvm/gems/ruby-2.0.0-p247/gems/cucumber-1.3.5/lib/cucumber/runtime.rb:42:in `run!'
  /home/user/.rvm/gems/ruby-2.0.0-p247/gems/cucumber-1.3.5/lib/cucumber/cli/main.rb:47:in `execute!'
  /home/user/.rvm/gems/ruby-2.0.0-p247/gems/cucumber-1.3.5/bin/cucumber:13:in `&lt;top (required)&gt;'
  /home/user/.rvm/gems/ruby-2.0.0-p247/bin/cucumber:23:in `load'
  /home/user/.rvm/gems/ruby-2.0.0-p247/bin/cucumber:23:in `&lt;main&gt;'
  /home/user/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
  /home/user/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `&lt;main&gt;'
  </code></pre>
  
  <p>Then I try to move <code>Watir.new</code> method inside <code>Before</code> block:</p>
  
  <pre><code>Before do
    if !$somevar
      browser = Watir::Browser.new ENV['BROWSER'].to_sym
      @browser = browser
      $somevar = true
    end
  end
  </code></pre>
  
  <p>And get error in <code>at_exit</code> block:</p>
  
  <pre><code>/home/user/work/repository/features/support/hooks.rb:26:in `block in &lt;top (required)&gt;': undefined local variable or method `browser' for main:Object (NameError)
  </code></pre>
  
  <p>If I put <code>@browser.close</code> inside <code>at_exit</code>, I get:</p>
  
  <pre><code>/home/user/work/repository/features/support/hooks.rb:26:in `block in &lt;top (required)&gt;': undefined method `close' for nil:NilClass (NoMethodError)
  </code></pre>
  
  <p>Is there any way to open/close the browser once in a test suite and make it work with the <code>-d</code> option of cucumber?</p>