File: token_authenticatable_spec.rb

package info (click to toggle)
ruby-devise-token-authenticatable 0.5.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 276 kB
  • sloc: ruby: 1,059; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,653 bytes parent folder | download | duplicates (2)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require 'spec_helper'

describe Devise::TokenAuthenticatable do
  context "configuring the token_expires_in" do
    let(:expire_time) { 1.hour }

    it "should set the configuration" do
      expect {
        Devise::TokenAuthenticatable.setup do |config|
          config.token_expires_in = expire_time
        end
      }.to change { Devise::TokenAuthenticatable.token_expires_in }.from(nil).to(expire_time)
    end
  end

  context "configuring the token_authentication_key" do
    let(:new_key) { :other_key }

    it "should set the configuration" do
      expect {
        Devise::TokenAuthenticatable.setup do |config|
          config.token_authentication_key = new_key
        end
      }.to change { Devise::TokenAuthenticatable.token_authentication_key }.from(:auth_token).to(new_key)
    end
  end

  context "configuring the should_reset_authentication_token" do
    let(:should_reset) { true }

    it "should set the configuration" do
      expect {
        Devise::TokenAuthenticatable.setup do |config|
          config.should_reset_authentication_token = should_reset
        end
      }.to change { Devise::TokenAuthenticatable.should_reset_authentication_token }.from(false).to(should_reset)
    end
  end

  context "configuring the should_ensure_authentication_token" do
    let(:should_ensure) { true }

    it "should set the configuration" do
      expect {
        Devise::TokenAuthenticatable.setup do |config|
          config.should_ensure_authentication_token = should_ensure
        end
      }.to change { Devise::TokenAuthenticatable.should_ensure_authentication_token }.from(false).to(should_ensure)
    end
  end
end