OSDN Git Service

t#31076:import methods move to model
[pettanr/pettanr.git] / spec / models / user_spec.rb
index 44032b4..9cc64f0 100644 (file)
@@ -1,5 +1,40 @@
+# -*- encoding: utf-8 -*-
+#ユーザアカウント
 require 'spec_helper'
 
 describe User do
-  pending "add some examples to (or delete) #{__FILE__}"
+  before do
+    @admin = FactoryGirl.create :admin
+  end
+
+  describe 'トークン作成に於いて' do
+    before do
+      @user = FactoryGirl.create( :user_yas)
+    end
+    it 'トークンが変更されている' do
+      lambda {
+        @user.create_token
+      }.should change(@user, :authentication_token)
+    end
+    it 'トークンが作成されている' do
+      @user.create_token
+      @user.authentication_token.should_not be_empty
+    end
+  end
+  
+  describe 'トークン削除に於いて' do
+    before do
+      @user = FactoryGirl.create( :user_yas)
+      @user.create_token
+    end
+    it 'トークンが変更されている' do
+      lambda {
+        @user.delete_token
+      }.should change(@user, :authentication_token)
+    end
+    it 'トークンが削除されている' do
+      @user.delete_token
+      @user.authentication_token.should be_blank
+    end
+  end
 end