Simple Rspec test fails - for what reason?
Coding one of my first rspec
tests. headers == nil
prints true
, but the next test line headers should be_nil
fails. Why?
require 'net/http'
$url_arr = []
$url_arr << ...
$url_arr << ...
$url_arr << ...
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 "==========> #{headers == nil}"
headers sho开发者_JS百科uld be_nil
end
end
end
Also, the output is
got: "new script" (using ==)
Why "new script" is printed, while headers
really contains nil
?
Try
headers.should be_nil
instead.
精彩评论