OSDN Git Service

t#31085:raise err when input invalid encoding string
[pettanr/pettanr.git] / spec / models / comic_spec.rb
index 35792c1..64acd7e 100644 (file)
@@ -61,6 +61,21 @@ describe Comic do
     end
   end
   
+  describe '文字コード検証に於いて' do
+    before do
+      @comic = FactoryGirl.build :comic, :author_id => @author.id
+    end
+    
+    context 'titleを検証するとき' do
+      it 'Shift JISなら失敗する' do
+        @comic.title = "\x83G\x83r\x83]\x83D"
+        lambda{
+          @comic.valid_encode
+        }.should raise_error(Pettanr::BadRequest)
+      end
+    end
+  end
+  
   describe 'デフォルト値補充に於いて' do
     it 'visibleが0になっている' do
       @comic = FactoryGirl.build :comic, :visible => nil