1 # -*- encoding: utf-8 -*-
\r
2 require 'spec_helper'
\r
6 FactoryGirl.create :admin
\r
7 @sp = FactoryGirl.create :system_picture
8 @lg = FactoryGirl.create :license_group
9 @l = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
10 @user = FactoryGirl.create( :user_yas)
\r
11 @author = @user.author
\r
13 @panel = FactoryGirl.create :panel
\r
14 @speech_balloon_template = FactoryGirl.create :speech_balloon_template
\r
15 @speech_balloon = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
\r
18 describe '検証に於いて' do
\r
19 it 'オーソドックスなデータなら通る' do
\r
20 @speech = FactoryGirl.build :speech, :speech_balloon_id => @speech_balloon.id
\r
21 @speech.should be_valid
\r
24 context 'speech_balloon_idを検証するとき' do
\r
26 @speech = FactoryGirl.build :speech, :speech_balloon_id => @speech_balloon.id
\r
28 #ネストの保存はnilを許可しなければならないので数値チェックだけ
30 @speech.speech_balloon_id = @speech_balloon.id
\r
31 @speech.should be_valid
\r
34 @speech.speech_balloon_id = 'a'
\r
35 @speech.should_not be_valid
\r
38 context 'contentを検証するとき' do
\r
40 context 'xを検証するとき' do
\r
42 @speech = FactoryGirl.build :speech, :speech_balloon_id => @speech_balloon.id
\r
46 @speech.should be_valid
\r
50 @speech.should_not be_valid
\r
54 @speech.should_not be_valid
\r
58 @speech.should be_valid
\r
62 @speech.should be_valid
\r
65 context 'yを検証するとき' do
\r
67 @speech = FactoryGirl.build :speech, :speech_balloon_id => @speech_balloon.id
\r
71 @speech.should be_valid
\r
75 @speech.should_not be_valid
\r
79 @speech.should_not be_valid
\r
83 @speech.should be_valid
\r
87 @speech.should be_valid
\r
90 context 'widthを検証するとき' do
\r
92 @speech = FactoryGirl.build :speech, :speech_balloon_id => @speech_balloon.id
\r
96 @speech.should be_valid
\r
100 @speech.should_not be_valid
\r
102 it '数値でなければ失敗する' do
\r
103 @speech.width = 'a'
\r
104 @speech.should_not be_valid
\r
107 @speech.width = '0'
\r
108 @speech.should_not be_valid
\r
112 @speech.should_not be_valid
\r
115 context 'heightを検証するとき' do
\r
117 @speech = FactoryGirl.build :speech, :speech_balloon_id => @speech_balloon.id
\r
120 @speech.height = '1'
\r
121 @speech.should be_valid
\r
124 @speech.height = nil
\r
125 @speech.should_not be_valid
\r
127 it '数値でなければ失敗する' do
\r
128 @speech.height = 'a'
\r
129 @speech.should_not be_valid
\r
132 @speech.height = '0'
\r
133 @speech.should_not be_valid
\r
136 @speech.height = -1
\r
137 @speech.should_not be_valid
\r
140 context 'settingsを検証するとき' do
\r
142 @speech = FactoryGirl.build :speech, :speech_balloon_id => @speech_balloon.id
\r
145 @speech.settings = ''
\r
146 @speech.should be_valid
\r