22
33require 'spec_helper'
44
5- class DummyUser
6- include RpiAuth ::Models ::Authenticatable
7- end
5+ RSpec . describe RpiAuth ::Models ::Authenticatable , type : :model do
6+ subject { user_class . new }
87
9- RSpec . describe DummyUser , type : :model do
10- subject { described_class . new }
8+ let ( :user_class ) do
9+ Class . new ( User ) do
10+ include RpiAuth ::Models ::Authenticatable
11+ end
12+ end
1113
1214 it { is_expected . to respond_to ( :user_id ) }
1315 it { is_expected . to respond_to ( :country ) }
@@ -22,11 +24,11 @@ class DummyUser
2224 it { is_expected . not_to respond_to ( :from_omniauth ) }
2325
2426 describe 'PROFILE_KEYS' do
25- it { expect ( described_class ::PROFILE_KEYS ) . to be_an ( Array ) }
27+ it { expect ( user_class ::PROFILE_KEYS ) . to be_an ( Array ) }
2628 end
2729
2830 describe '#from_omniauth' do
29- subject ( :omniauth_user ) { described_class . from_omniauth ( auth ) }
31+ subject ( :omniauth_user ) { user_class . from_omniauth ( auth ) }
3032
3133 let ( :info ) do
3234 {
@@ -53,7 +55,7 @@ class DummyUser
5355 end
5456
5557 it 'returns a user with the correct attributes' do
56- expect ( omniauth_user ) . to be_a described_class
58+ expect ( omniauth_user ) . to be_a user_class
5759 expect ( omniauth_user ) . to have_attributes ( user_id : 'testuserid' , name : 'Bodkin Van Horn' ,
5860 nickname :
'Hoos-Foos' , email :
'[email protected] ' , 5961 country : 'Zimbabwe' , country_code : 'ZW' ,
@@ -64,13 +66,13 @@ class DummyUser
6466 context 'with unusual keys in info' do
6567 let ( :info ) { { foo : :bar , flibble : :woo } }
6668
67- it { is_expected . to be_a described_class }
69+ it { is_expected . to be_a user_class }
6870 end
6971
7072 context 'with no info' do
7173 let ( :info ) { nil }
7274
73- it { is_expected . to be_a described_class }
75+ it { is_expected . to be_a user_class }
7476 end
7577
7678 context 'with no auth set' do
0 commit comments