Sha256: fffc81fd45d8e012410415a6032d4f15f61ad5902bf3232508fc9d86b70d2b85

Contents?: true

Size: 1.01 KB

Versions: 179

Compression:

Stored size: 1.01 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

end

Version data entries

179 entries across 153 versions & 27 rubygems

Version Path
classiccms-0.5.16 vendor/bundle/gems/rack-1.4.1/test/spec_session_abstract_id.rb
classiccms-0.5.15 vendor/bundle/gems/rack-1.4.1/test/spec_session_abstract_id.rb
classiccms-0.5.14 vendor/bundle/gems/rack-1.4.1/test/spec_session_abstract_id.rb
classiccms-0.5.13 vendor/bundle/gems/rack-1.4.1/test/spec_session_abstract_id.rb
classiccms-0.5.12 vendor/bundle/gems/rack-1.4.1/test/spec_session_abstract_id.rb
classiccms-0.5.11 vendor/bundle/gems/rack-1.4.1/test/spec_session_abstract_id.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/test/spec_session_abstract_id.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/test/spec_session_abstract_id.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/test/spec_session_abstract_id.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/test/spec_session_abstract_id.rb
challah-rolls-0.1.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/rack-1.4.1/test/spec_session_abstract_id.rb
challah-rolls-0.1.0 vendor/bundle/gems/rack-1.4.1/test/spec_session_abstract_id.rb
challah-0.8.0.pre vendor/bundle/gems/rack-1.4.1/test/spec_session_abstract_id.rb
challah-0.7.1 vendor/bundle/gems/rack-1.4.1/test/spec_session_abstract_id.rb
bitclust-core-0.5.2 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/test/spec_session_abstract_id.rb
bitclust-core-0.5.2 vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/test/spec_session_abstract_id.rb
classiccms-0.5.10 vendor/bundle/gems/rack-1.4.1/test/spec_session_abstract_id.rb
classiccms-0.5.9 vendor/bundle/gems/rack-1.4.1/test/spec_session_abstract_id.rb
challah-0.7.0 vendor/bundle/gems/rack-1.4.1/test/spec_session_abstract_id.rb
challah-0.7.0.pre2 vendor/bundle/gems/rack-1.4.1/test/spec_session_abstract_id.rb