summaryrefslogtreecommitdiff
path: root/spec/ruby/library/cgi/queryextension/remote_host_spec.rb
blob: c4db9e4ffe84d8df5079ec48c53cd38acd8f9274 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require_relative '../../../spec_helper'

ruby_version_is ""..."3.5" do
  require 'cgi'

  describe "CGI::QueryExtension#remote_host" do
    before :each do
      ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
      @cgi = CGI.new
    end

    after :each do
      ENV['REQUEST_METHOD'] = @old_request_method
    end

    it "returns ENV['REMOTE_HOST']" do
      old_value, ENV['REMOTE_HOST'] = ENV['REMOTE_HOST'], "test.host"
      begin
        @cgi.remote_host.should == "test.host"
      ensure
        ENV['REMOTE_HOST'] = old_value
      end
    end
  end
end