title: Simple Rspec test fails - for what reason?
body: <p>Coding one of my first <code>rspec</code> tests. <code>headers == nil</code> prints <code>true</code>, but the next test line <code>headers should be_nil</code> fails. Why?</p>
  
  <pre><code>require 'net/http'
  
  $url_arr = []
  $url_arr &lt;&lt; ...
  $url_arr &lt;&lt; ...
  $url_arr &lt;&lt; ...
  
  module NetHelpers
      def get_headers(uri)
          Net::HTTP.get_response(URI.parse(uri)).get_fields('Set-Cookie')
      end
  end
  
  describe "new script" do
      include NetHelpers
  
      $url_arr.each do |uri|
          it "should not return cookies" do
              headers = get_headers(uri)
              p "==========&gt; #{headers == nil}"
              headers should be_nil
          end
      end
  end
  </code></pre>
  
  <p>Also, the output is</p>
  
  <blockquote>
    <p>got: "new script" (using ==)</p>
  </blockquote>
  
  <p>Why <em>"new script"</em> is printed, while <code>headers</code> really contains <code>nil</code>?</p>