Sha256: ca577fd942de7a63ddad75fe988aa2c4e7b6698410a7d7f9530de9cc85492de3

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

require 'test_helper'
require 'camping'
require 'camping/session'

Camping.goes :Sessions

module Sessions
  include Camping::Session
end

module Sessions::Controllers
  class One
    def get
      @state.clear
      @state.one = 42
      redirect R(Two)
    end
  end

  class Two
    def get
      @state.two = 56
      redirect R(Three)
    end
  end

  class Three
    def get
      @state.three = 99
      @state.values_at("one", "two", "three").inspect
    end
  end
end

class Sessions::Test < TestCase
  def test_session
    get '/one'
    follow_redirect!
    follow_redirect!
    assert_body "[42, 56, 99]"
  end

  def test_secret_length
    app.set :secret, "whateverloser"
    begin
      app.include Camping::Session
    rescue InsecureSecret => e
      message = "You're Session Secret is too short. Minimum length is 64."
      assert_equal(e.message, message, "You're session secret wasn't long enough.")
    end

    e = "empty"
    message = "empty"
    begin
      app.set :secret, "whateverloserwhateverloserwhateverloserwhateverloserwhateverloser"
      app.include Camping::Session
    rescue InsecureSecret => e
      message = e
    end

    assert_equal(e, message, "You're session secret wasn't long enough.")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
camping-3.0.2 test/app_sessions.rb
camping-3.0.1 test/app_sessions.rb
camping-3.0.0 test/app_sessions.rb