Sha256: c314190279380a11586afdd9cf6ee6f226c48284e4af562cfe0fb642fabfe4dc
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
### WARNING: there be hax in this file. require 'rack/session/abstract/id' describe Rack::Session::Abstract::ID do id = Rack::Session::Abstract::ID def silence_warning o, $VERBOSE = $VERBOSE, nil yield ensure $VERBOSE = o end def reload_id $".delete $".find { |part| part =~ %r{session/abstract/id.rb} } silence_warning { require 'rack/session/abstract/id' } end should "use securerandom when available" do begin fake = false silence_warning do ::SecureRandom = fake = true unless defined?(SecureRandom) end reload_id id::DEFAULT_OPTIONS[:secure_random].should.eql(fake || SecureRandom) ensure Object.send(:remove_const, :SecureRandom) if fake end end should "not use securerandom when unavailable" do begin sr = Object.send(:remove_const, :SecureRandom) if defined?(SecureRandom) reload_id id::DEFAULT_OPTIONS[:secure_random].should.eql false ensure ::SecureRandom = sr if defined?(sr) end end should "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).should.equal 'fake_hex' end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rack-1.6.13 | test/spec_session_abstract_id.rb |
rack-1.6.12 | test/spec_session_abstract_id.rb |