rack.git  about / heads / tags
a modular Ruby webserver interface
blob 3591a3dea145f09e15465f149130040f51b99c71 736 bytes (raw)
$ git show no-unicorn:test/spec_session_abstract_id.rb	# shows this blob on the CLI

 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
26
27
28
29
30
31
32
33
 
# frozen_string_literal: true

require 'minitest/global_expectations/autorun'
### WARNING: there be hax in this file.

require 'rack/session/abstract/id'

describe Rack::Session::Abstract::ID do
  attr_reader :id

  def setup
    super
    @id = Rack::Session::Abstract::ID
  end

  it "use securerandom" do
    assert_equal ::SecureRandom, id::DEFAULT_OPTIONS[:secure_random]

    id = @id.new nil
    assert_equal ::SecureRandom, id.sid_secure
  end

  it "allow to use another securerandom provider" do
    secure_random = Class.new do
      def hex(*args)
        'fake_hex'
      end
    end
    id = Rack::Session::Abstract::ID.new nil, secure_random: secure_random.new
    id.send(:generate_sid).must_equal 'fake_hex'
  end

end

git clone https://yhbt.net/rack.git