OSDN Git Service

pass test
[pettanr/pettanr.git] / spec / models / speech_spec.rb
1 # -*- encoding: utf-8 -*-\r
2 require 'spec_helper'\r
3 \r
4 describe Speech do\r
5   before do\r
6     Factory :admin\r
7     @license = Factory :license\r
8     @user = Factory( :user_yas)\r
9     @author = @user.author\r
10     \r
11     @panel = Factory :panel\r
12     @speech_balloon_template = Factory :speech_balloon_template\r
13     @speech_balloon = Factory :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
14   end\r
15   \r
16   describe '検証に於いて' do\r
17     it 'オーソドックスなデータなら通る' do\r
18       @speech = Factory.build :speech, :speech_balloon_id => @speech_balloon.id\r
19       @speech.should be_valid\r
20     end\r
21     \r
22     context 'speech_balloon_idを検証するとき' do\r
23       before do\r
24         @speech = Factory.build :speech, :speech_balloon_id => @speech_balloon.id\r
25       end\r
26       it 'テストデータの確認' do\r
27         @speech.speech_balloon_id = @speech_balloon.id\r
28         @speech.should be_valid\r
29       end\r
30       it '数値でなければ失敗する' do\r
31         @speech.speech_balloon_id = 'a'\r
32         @speech.should_not be_valid\r
33       end\r
34     end\r
35     context 'contentを検証するとき' do\r
36     end\r
37     context 'xを検証するとき' do\r
38       before do\r
39         @speech = Factory.build :speech, :speech_balloon_id => @speech_balloon.id\r
40       end\r
41       it 'テストデータの確認' do\r
42         @speech.x = '1'\r
43         @speech.should be_valid\r
44       end\r
45       it 'nullなら失敗する' do\r
46         @speech.x = nil\r
47         @speech.should_not be_valid\r
48       end\r
49       it '数値でなければ失敗する' do\r
50         @speech.x = 'a'\r
51         @speech.should_not be_valid\r
52       end\r
53       it '0なら通る' do\r
54         @speech.x = '0'\r
55         @speech.should be_valid\r
56       end\r
57       it '負でも通る' do\r
58         @speech.x = -1\r
59         @speech.should be_valid\r
60       end\r
61     end\r
62     context 'yを検証するとき' do\r
63       before do\r
64         @speech = Factory.build :speech, :speech_balloon_id => @speech_balloon.id\r
65       end\r
66       it 'テストデータの確認' do\r
67         @speech.y = '1'\r
68         @speech.should be_valid\r
69       end\r
70       it 'nullなら失敗する' do\r
71         @speech.y = nil\r
72         @speech.should_not be_valid\r
73       end\r
74       it '数値でなければ失敗する' do\r
75         @speech.y = 'a'\r
76         @speech.should_not be_valid\r
77       end\r
78       it '0なら通る' do\r
79         @speech.y = '0'\r
80         @speech.should be_valid\r
81       end\r
82       it '負でも通る' do\r
83         @speech.y = -1\r
84         @speech.should be_valid\r
85       end\r
86     end\r
87     context 'widthを検証するとき' do\r
88       before do\r
89         @speech = Factory.build :speech, :speech_balloon_id => @speech_balloon.id\r
90       end\r
91       it 'テストデータの確認' do\r
92         @speech.width = 1\r
93         @speech.should be_valid\r
94       end\r
95       it 'nullなら失敗する' do\r
96         @speech.width = nil\r
97         @speech.should_not be_valid\r
98       end\r
99       it '数値でなければ失敗する' do\r
100         @speech.width = 'a'\r
101         @speech.should_not be_valid\r
102       end\r
103       it '0なら失敗する' do\r
104         @speech.width = '0'\r
105         @speech.should_not be_valid\r
106       end\r
107       it '負でも失敗する' do\r
108         @speech.width = -1\r
109         @speech.should_not be_valid\r
110       end\r
111     end\r
112     context 'heightを検証するとき' do\r
113       before do\r
114         @speech = Factory.build :speech, :speech_balloon_id => @speech_balloon.id\r
115       end\r
116       it 'テストデータの確認' do\r
117         @speech.height = '1'\r
118         @speech.should be_valid\r
119       end\r
120       it 'nullなら失敗する' do\r
121         @speech.height = nil\r
122         @speech.should_not be_valid\r
123       end\r
124       it '数値でなければ失敗する' do\r
125         @speech.height = 'a'\r
126         @speech.should_not be_valid\r
127       end\r
128       it '0なら失敗する' do\r
129         @speech.height = '0'\r
130         @speech.should_not be_valid\r
131       end\r
132       it '負でも失敗する' do\r
133         @speech.height = -1\r
134         @speech.should_not be_valid\r
135       end\r
136     end\r
137     context 'settingsを検証するとき' do\r
138       before do\r
139         @speech = Factory.build :speech, :speech_balloon_id => @speech_balloon.id\r
140       end\r
141       it 'テストデータの確認' do\r
142         @speech.settings = ''\r
143         @speech.should be_valid\r
144       end\r
145     end\r
146   end\r
147   \r
148 end\r