Module: Bouncer::TestHelpers

Defined in:
lib/bouncer-client/test_helpers.rb

Instance Method Summary collapse

Instance Method Details

#machine_token(id = SecureRandom.uuid) ⇒ Object



15
16
17
18
19
# File 'lib/bouncer-client/test_helpers.rb', line 15

def machine_token id = SecureRandom.uuid
  token = valid_token id
  allow(token).to receive(:device?).and_return(true)
  token
end

#super_admin_token(id = SecureRandom.uuid) ⇒ Object



3
4
5
6
7
# File 'lib/bouncer-client/test_helpers.rb', line 3

def super_admin_token id = SecureRandom.uuid
  token = user_token id
  allow(token).to receive(:super_admin?).and_return(true)
  token
end

#user_token(id = SecureRandom.uuid) ⇒ Object



9
10
11
12
13
# File 'lib/bouncer-client/test_helpers.rb', line 9

def user_token id = SecureRandom.uuid
  token = valid_token id
  allow(token).to receive(:user?).and_return(true)
  token
end

#valid_token(mock_id = "abunchofcrap") ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bouncer-client/test_helpers.rb', line 21

def valid_token mock_id = "abunchofcrap"
  token = double("Bouncer::Token")
  allow(token).to receive(:validate!).and_return(true)
  allow(token).to receive(:id).and_return(mock_id.to_s)
  allow(token).to receive(:device?)
  allow(token).to receive(:user?)
  allow(token).to receive(:super_admin?)
  allow(Bouncer::Token).to receive(:present?).and_return(true)
  allow(Bouncer::Token).to receive(:new).and_return(token)
  token
end