OSDN Git Service

t#30200:update i18n devise
[pettanr/pettanr.git] / spec / models / balloon_spec.rb
index a9c7e3b..17f0b58 100644 (file)
@@ -1,5 +1,139 @@
-require 'spec_helper'
-
-describe Balloon do
-  pending "add some examples to (or delete) #{__FILE__}"
-end
+# -*- encoding: utf-8 -*-\r
+require 'spec_helper'\r
+#セリフ\r
+describe Balloon do\r
+  before do\r
+    @admin = FactoryGirl.create :admin\r
+    @user = FactoryGirl.create( :user_yas)\r
+    @author = FactoryGirl.create :author, :user_id => @user.id\r
+    @artist = FactoryGirl.create :artist_yas, :author_id => @author.id\r
+    \r
+    @balloon = FactoryGirl.create :panel\r
+    @speech_balloon_template = FactoryGirl.create :speech_balloon_template\r
+    @speech_balloon = FactoryGirl.create :speech_balloon, :panel_id => @balloon.id, :speech_balloon_template_id => @speech_balloon_template.id\r
+    @system_picture = FactoryGirl.create :system_picture\r
+  end\r
+  \r
+  describe '検証に於いて' do\r
+    before do\r
+      @balloon = FactoryGirl.build :balloon, :speech_balloon_id => @speech_balloon.id, :system_picture_id => @system_picture.id\r
+    end\r
+    context 'オーソドックスなデータのとき' do\r
+      it '下限データが通る' do\r
+        @balloon.x = 0\r
+        @balloon.y = 0\r
+        @balloon.width = 1\r
+        @balloon.height = 1\r
+        @balloon.should be_valid\r
+      end\r
+      it '上限データが通る' do\r
+        @balloon.x = 99999\r
+        @balloon.y = 99999\r
+        @balloon.width = 99999\r
+        @balloon.height = 99999\r
+        @balloon.should be_valid\r
+      end\r
+    end\r
+    \r
+    context 'speech_balloon_idを検証するとき' do\r
+      #ネストの保存はnilを許可しなければならないので数値チェックだけ\r
+      it 'テストデータの確認' do\r
+        @balloon.speech_balloon_id = @speech_balloon.id\r
+        @balloon.should be_valid\r
+      end\r
+      it '数値でなければ失敗する' do\r
+        @balloon.speech_balloon_id = 'a'\r
+        @balloon.should_not be_valid\r
+      end\r
+    end\r
+    context 'system_picture_idを検証するとき' do\r
+      it 'nullなら失敗する' do\r
+        @balloon.system_picture_id = nil\r
+        @balloon.should_not be_valid\r
+      end\r
+      it '数値でなければ失敗する' do\r
+        @balloon.system_picture_id = 'a'\r
+        @balloon.should_not be_valid\r
+      end\r
+      it '存在するシステム画像でなければ失敗する' do\r
+        @balloon.system_picture_id = 0\r
+        @balloon.should_not be_valid\r
+      end\r
+    end\r
+    context 'xを検証するとき' do\r
+      it 'nullなら失敗する' do\r
+        @balloon.x = nil\r
+        @balloon.should_not be_valid\r
+      end\r
+      it '数値でなければ失敗する' do\r
+        @balloon.x = 'a'\r
+        @balloon.should_not be_valid\r
+      end\r
+      it '0なら通る' do\r
+        @balloon.x = '0'\r
+        @balloon.should be_valid\r
+      end\r
+      it '負でも通る' do\r
+        @balloon.x = -1\r
+        @balloon.should be_valid\r
+      end\r
+    end\r
+    context 'yを検証するとき' do\r
+      it 'nullなら失敗する' do\r
+        @balloon.y = nil\r
+        @balloon.should_not be_valid\r
+      end\r
+      it '数値でなければ失敗する' do\r
+        @balloon.y = 'a'\r
+        @balloon.should_not be_valid\r
+      end\r
+      it '0なら通る' do\r
+        @balloon.y = '0'\r
+        @balloon.should be_valid\r
+      end\r
+      it '負でも通る' do\r
+        @balloon.y = -1\r
+        @balloon.should be_valid\r
+      end\r
+    end\r
+    context 'widthを検証するとき' do\r
+      it 'nullなら失敗する' do\r
+        @balloon.width = nil\r
+        @balloon.should_not be_valid\r
+      end\r
+      it '数値でなければ失敗する' do\r
+        @balloon.width = 'a'\r
+        @balloon.should_not be_valid\r
+      end\r
+      it '0なら失敗する' do\r
+        @balloon.width = '0'\r
+        @balloon.should_not be_valid\r
+      end\r
+      it '負でも失敗する' do\r
+        @balloon.width = -1\r
+        @balloon.should_not be_valid\r
+      end\r
+    end\r
+    context 'heightを検証するとき' do\r
+      it 'nullなら失敗する' do\r
+        @balloon.height = nil\r
+        @balloon.should_not be_valid\r
+      end\r
+      it '数値でなければ失敗する' do\r
+        @balloon.height = 'a'\r
+        @balloon.should_not be_valid\r
+      end\r
+      it '0なら失敗する' do\r
+        @balloon.height = '0'\r
+        @balloon.should_not be_valid\r
+      end\r
+      it '負でも失敗する' do\r
+        @balloon.height = -1\r
+        @balloon.should_not be_valid\r
+      end\r
+    end\r
+    context 'settingsを検証するとき' do\r
+    end\r
+  end\r
+  \r
+end\r