OSDN Git Service

pass test
[pettanr/pettanr.git] / spec / models / user_spec.rb
1 # -*- encoding: utf-8 -*-
2 #ユーザアカウント
3 require 'spec_helper'
4
5 describe User do
6   before do
7     Factory :admin
8   end
9
10   describe '作成に於いて' do
11     context '作家の自動作成' do
12       it '作家が作成されている' do
13         lambda {
14           @user = Factory( :user_yas)
15         }.should change(Author, :count)
16       end
17       it '作家とユーザがリンクされている' do
18         @user = Factory( :user_yas)
19         Author.find_by_user_id(@user.id).should_not eq nil
20       end
21     end
22   end
23   
24   describe 'トークン作成に於いて' do
25     before do
26       @user = Factory( :user_yas)
27     end
28     it 'トークンが変更されている' do
29       lambda {
30         @user.create_token
31       }.should change(@user, :authentication_token)
32     end
33     it 'トークンが作成されている' do
34       @user.create_token
35       @user.authentication_token.should_not be_empty
36     end
37   end
38   
39   describe 'トークン削除に於いて' do
40     before do
41       @user = Factory( :user_yas)
42       @user.create_token
43     end
44     it 'トークンが変更されている' do
45       lambda {
46         @user.delete_token
47       }.should change(@user, :authentication_token)
48     end
49     it 'トークンが削除されている' do
50       @user.delete_token
51       @user.authentication_token.should be_blank
52     end
53   end
54 end