OSDN Git Service

e859c4b63c4548eeb117e4ff99d92c477d3cf003
[pettanr/pettanr.git] / spec / models / balloon_spec.rb
1 # -*- encoding: utf-8 -*-\r
2 require 'spec_helper'
3
4 describe Balloon do
5   before do
6     Factory :admin
7     @user = Factory( :user_yas)
8     @author = @user.author
9     @artist = Factory :artist_yas, :author_id => @author.id\r
10     @license = Factory :license
11     
12     @balloon = Factory :panel
13     @speech_balloon_template = Factory :speech_balloon_template
14     @speech_balloon = Factory :speech_balloon, :panel_id => @balloon.id, :speech_balloon_template_id => @speech_balloon_template.id\r
15     @system_picture = Factory :system_picture
16   end\r
17   
18   describe '検証に於いて' do
19     before do\r
20     end
21     
22     it 'オーソドックスなデータなら通る' do
23       @balloon = Factory.build :balloon, :speech_balloon_id => @speech_balloon.id, :system_picture_id => @system_picture.id
24       @balloon.should be_valid
25     end
26     
27     context 'speech_balloon_idを検証するとき' do
28       before do
29         @balloon = Factory.build :balloon, :speech_balloon_id => @speech_balloon.id, :system_picture_id => @system_picture.id
30       end
31       it 'テストデータの確認' do
32         @balloon.speech_balloon_id = @speech_balloon.id
33         @balloon.should be_valid
34       end
35       it 'nullなら失敗する' do
36         @balloon.speech_balloon_id = nil
37         @balloon.should_not be_valid
38       end
39       it '数値でなければ失敗する' do
40         @balloon.speech_balloon_id = 'a'
41         @balloon.should_not be_valid
42       end
43       it '存在するフキダシでなければ失敗する' do
44         @balloon.speech_balloon_id = 0
45         @balloon.should_not be_valid
46       end
47     end
48     context 'system_picture_idを検証するとき' do
49       before do
50         @balloon = Factory.build :balloon, :speech_balloon_id => @speech_balloon.id, :system_picture_id => @system_picture.id
51       end
52       it 'テストデータの確認' do
53         @balloon.system_picture_id = @system_picture.id
54         @balloon.should be_valid
55       end
56       it 'nullなら失敗する' do
57         @balloon.system_picture_id = nil
58         @balloon.should_not be_valid
59       end
60       it '数値でなければ失敗する' do
61         @balloon.system_picture_id = 'a'
62         @balloon.should_not be_valid
63       end
64       it '存在するシステム画像でなければ失敗する' do
65         @balloon.system_picture_id = 0
66         @balloon.should_not be_valid
67       end
68     end
69     context 'xを検証するとき' do
70       before do
71         @balloon = Factory.build :balloon, :speech_balloon_id => @speech_balloon.id, :system_picture_id => @system_picture.id
72       end
73       it 'テストデータの確認' do
74         @balloon.x = '1'
75         @balloon.should be_valid
76       end
77       it 'nullなら失敗する' do
78         @balloon.x = nil
79         @balloon.should_not be_valid
80       end
81       it '数値でなければ失敗する' do
82         @balloon.x = 'a'
83         @balloon.should_not be_valid
84       end
85       it '0なら通る' do
86         @balloon.x = '0'
87         @balloon.should be_valid
88       end
89       it '負でも通る' do
90         @balloon.x = -1
91         @balloon.should be_valid
92       end
93     end
94     context 'yを検証するとき' do
95       before do
96         @balloon = Factory.build :balloon, :speech_balloon_id => @speech_balloon.id, :system_picture_id => @system_picture.id
97       end
98       it 'テストデータの確認' do
99         @balloon.y = '1'
100         @balloon.should be_valid
101       end
102       it 'nullなら失敗する' do
103         @balloon.y = nil
104         @balloon.should_not be_valid
105       end
106       it '数値でなければ失敗する' do
107         @balloon.y = 'a'
108         @balloon.should_not be_valid
109       end
110       it '0なら通る' do
111         @balloon.y = '0'
112         @balloon.should be_valid
113       end
114       it '負でも通る' do
115         @balloon.y = -1
116         @balloon.should be_valid
117       end
118     end
119     context 'widthを検証するとき' do
120       before do
121         @balloon = Factory.build :balloon, :speech_balloon_id => @speech_balloon.id, :system_picture_id => @system_picture.id
122       end
123       it 'テストデータの確認' do
124         @balloon.width = 1
125         @balloon.should be_valid
126       end
127       it 'nullなら失敗する' do
128         @balloon.width = nil
129         @balloon.should_not be_valid
130       end
131       it '数値でなければ失敗する' do
132         @balloon.width = 'a'
133         @balloon.should_not be_valid
134       end
135       it '0なら失敗する' do
136         @balloon.width = '0'
137         @balloon.should_not be_valid
138       end
139       it '負でも失敗する' do
140         @balloon.width = -1
141         @balloon.should_not be_valid
142       end
143     end
144     context 'heightを検証するとき' do
145       before do
146         @balloon = Factory.build :balloon, :speech_balloon_id => @speech_balloon.id, :system_picture_id => @system_picture.id
147       end
148       it 'テストデータの確認' do
149         @balloon.height = '1'
150         @balloon.should be_valid
151       end
152       it 'nullなら失敗する' do
153         @balloon.height = nil
154         @balloon.should_not be_valid
155       end
156       it '数値でなければ失敗する' do
157         @balloon.height = 'a'
158         @balloon.should_not be_valid
159       end
160       it '0なら失敗する' do
161         @balloon.height = '0'
162         @balloon.should_not be_valid
163       end
164       it '負でも失敗する' do
165         @balloon.height = -1
166         @balloon.should_not be_valid
167       end
168     end
169     context 'settingsを検証するとき' do
170       before do
171         @balloon = Factory.build :balloon, :speech_balloon_id => @speech_balloon.id, :system_picture_id => @system_picture.id
172       end
173       it 'テストデータの確認' do
174         @balloon.settings = ''
175         @balloon.should be_valid
176       end
177     end
178   end
179   
180   describe 'データ補充に於いて' do
181     before do
182     end
183     
184   end
185   \r
186 end