OSDN Git Service

add test
[pettanr/pettanr.git] / spec / manifests / speech_balloon_spec.rb
1 # -*- encoding: utf-8 -*-
2 require 'spec_helper'
3 #フキダシ
4
5 describe SpeechBalloon do
6   include ManifestsMacros
7   before do
8     @model = SpeechBalloon
9   end
10   
11   describe 'ペタナイズに於いて' do
12     it 'パネルの要素として利用されるエレメントである' do
13       expect(@model.ancestors.include?(Peta::Element)).to eq true
14     end
15     it '親モデルはパネルである' do
16       expect(@model.my_peta.parent_model_name).to eq 'panel'
17     end
18     describe 'ブーストに於いて' do
19       before do
20         @boosts = @model.my_peta.boost
21         @boosts_names = ['speech_balloon_template']
22       end
23       it 'これらのブーストが定義されている' do
24         set_boosts? @boosts, @boosts_names
25       end
26       describe 'フキダシテンプレートに於いて' do
27         before do
28           @mani = @boosts['speech_balloon_template']
29         end
30         it 'フキダシテンプレート' do
31           expect(@mani.level).to eq 'post'
32           expect(@mani.template_name).to eq 'speech_balloon_template'
33           expect(@mani.column_name_for_template_module).to eq 'speech_balloon_template_module_name'
34           expect(@mani.settings_column_name).to eq 'speech_balloon_template_settings'
35           expect(@mani.foreign_key).to eq 'speech_balloon_template_id'
36         end
37         it 'フキダシテンプレート' do
38           expect(@mani.item_name_for_extend_model).to eq 'speech_balloon'
39           expect(@mani.setter_method_name).to eq 'speech_balloon_extend='
40           expect(@mani.getter_method_name).to eq 'speech_balloon_extend'
41           expect(@mani.extend_model_class_name).to eq 'SpeechBalloon'
42           expect(@mani.extend_module_name).to eq 'SpeechBalloonModule'
43         end
44       end
45     end
46     
47   end
48   
49   describe 'コントローラに於いて' do
50     before do
51       @controller = @model.my_controller
52     end
53     it 'コマ絵のためのコントローラである' do
54       expect(@model.item_name).to eq 'speech_balloon'
55     end
56     describe 'actionに於いて' do
57       before do
58         @actions = @controller.actions
59         @actions_names = ['index', 'by_author', 'by_panel', 'by_speech_balloon_template', 'show', 
60           'count', 'count_by_author', 'count_by_panel', 'count_by_speech_balloon_template', 
61           'new', 'edit']
62       end
63       it 'これらのアクションが定義されている' do
64         set_actions? @actions, @actions_names
65       end
66       describe 'baseに於いて' do
67       end
68       describe 'indexに於いて' do
69         before do
70           @action = @actions['index']
71         end
72         it 'listタイプのアクションである' do
73           expect(@action.type).to eq 'list'
74         end
75         it 'マニフェストから設定を取り出している' do
76           # コマ絵の公開リストを返すように定義している
77           set_list_action? @action, 'speech_balloon', 'public'
78         end
79       end
80       describe 'by_authorに於いて' do
81         before do
82           @action = @actions['by_author']
83         end
84         it 'listタイプのアクションである' do
85           expect(@action.type).to eq 'list'
86         end
87         it 'マニフェストから設定を取り出している' do
88           # コマ絵の作家フィルタリストを返すように定義している
89           set_list_action? @action, 'speech_balloon', 'by_author'
90         end
91       end
92       describe 'by_panelに於いて' do
93         before do
94           @action = @actions['by_panel']
95         end
96         it 'listタイプのアクションである' do
97           expect(@action.type).to eq 'list'
98         end
99         it 'マニフェストから設定を取り出している' do
100           #コマ絵のコマフィルタリストを返すように定義している
101           set_list_action? @action, 'speech_balloon', 'by_panel'
102         end
103       end
104       describe 'by_speech_balloon_templateに於いて' do
105         before do
106           @action = @actions['by_speech_balloon_template']
107         end
108         it 'listタイプのアクションである' do
109           expect(@action.type).to eq 'list'
110         end
111         it 'マニフェストから設定を取り出している' do
112           # コマ絵のフキダシテンプレートフィルタリストを返すように定義している
113           set_list_action? @action, 'speech_balloon', 'by_speech_balloon_template'
114         end
115       end
116       describe 'showに於いて' do
117         before do
118           @action = @actions['show']
119         end
120         it 'showタイプのアクションである' do
121           expect(@action.type).to eq 'show'
122         end
123       end
124       describe 'countに於いて' do
125         before do
126           @action = @actions['count']
127         end
128         it 'countタイプのアクションである' do
129           expect(@action.type).to eq 'count'
130         end
131         it 'マニフェストから設定を取り出している' do
132           #コマ絵の公開リストのカウントを返すように定義している
133           set_list_action? @action, 'speech_balloon', 'public'
134         end
135       end
136       describe 'count_by_authorに於いて' do
137         before do
138           @action = @actions['count_by_author']
139         end
140         it 'countタイプのアクションである' do
141           expect(@action.type).to eq 'count'
142         end
143         it 'マニフェストから設定を取り出している' do
144           # コマ絵の作家フィルタリストのカウントを返すように定義している
145           set_list_action? @action, 'speech_balloon', 'by_author'
146         end
147       end
148       describe 'count_by_panelに於いて' do
149         before do
150           @action = @actions['count_by_panel']
151         end
152         it 'countタイプのアクションである' do
153           expect(@action.type).to eq 'count'
154         end
155         it 'マニフェストから設定を取り出している' do
156           # コマ絵のコマフィルタリストのカウントを返すように定義している
157           set_list_action? @action, 'speech_balloon', 'by_panel'
158         end
159       end
160       describe 'count_by_speech_balloon_templateに於いて' do
161         before do
162           @action = @actions['count_by_speech_balloon_template']
163         end
164         it 'countタイプのアクションである' do
165           expect(@action.type).to eq 'count'
166         end
167         it 'マニフェストから設定を取り出している' do
168           # コマ絵のフキダシテンプレートフィルタリストのカウントを返すように定義している
169           set_list_action? @action, 'speech_balloon', 'by_speech_balloon_template'
170         end
171       end
172       describe 'newに於いて' do
173         before do
174           @action = @actions['new']
175         end
176         it 'newタイプのアクションである' do
177           expect(@action.type).to eq 'new'
178         end
179         it 'type' do
180           expect(@action.item_name).to eq 'speech_balloon'
181         end
182       end
183       describe 'editに於いて' do
184         before do
185           @action = @actions['edit']
186         end
187         it 'editタイプのアクションである' do
188           expect(@action.type).to eq 'edit'
189         end
190         it 'type' do
191           expect(@action.item_name).to eq 'speech_balloon'
192         end
193       end
194     end
195     
196   end
197   
198   describe 'モデルに於いて' do
199     before do
200       @my_manifest = @model.my_manifest
201     end
202     it 'サポート機能が動作している' do
203       expect(@my_manifest.model_name).to eq 'speech_balloon'
204       expect(@my_manifest.classify).to eq @model
205       expect(@my_manifest.table_name).to eq 'speech_balloons'
206     end
207     
208     describe 'associationsに於いて' do
209       describe 'belongs_toに於いて' do
210         before do
211           @belongs_to = @my_manifest.associations.belongs_to
212           @names = ['panel', 'speech_balloon_template']
213         end
214         it 'これらのモデルに所属している' do
215           set_associations? @belongs_to, @names
216         end
217         describe 'panelに於いて' do
218           before do
219             @mani = @belongs_to['panel']
220           end
221           it 'マニフェストから設定を取り出している' do
222             # モデル名と外部キーが定義あるいはデフォルト値補充されている
223             expect(@mani.model_name).to eq 'panel'
224             expect(@mani.id_column).to eq 'panel_id'
225           end
226           it 'サポート機能が動作している' do
227             # モデルを再現できている
228             expect(@mani.model).to eq Panel
229           end
230         end
231         describe 'speech_balloon_templateに於いて' do
232           before do
233             @mani = @belongs_to['speech_balloon_template']
234           end
235           it 'マニフェストから設定を取り出している' do
236             # モデル名と外部キーが定義あるいはデフォルト値補充されている
237             expect(@mani.model_name).to eq 'speech_balloon_template'
238             expect(@mani.id_column).to eq 'speech_balloon_template_id'
239           end
240           it 'サポート機能が動作している' do
241             # モデルを再現できている
242             expect(@mani.model).to eq SpeechBalloonTemplate
243           end
244         end
245       end
246       describe 'has_oneに於いて' do
247         before do
248           @has_one = @model.my_manifest.associations.has_one
249           @names = ['balloon', 'speech']
250         end
251         it 'これらのモデルを所持している' do
252           set_associations? @has_one, @names
253         end
254         describe 'balloonに於いて' do
255           before do
256             @mani = @has_one['balloon']
257           end
258           it 'マニフェストから設定を取り出している' do
259             # モデル名, 外部キーが定義あるいはデフォルト値補充されている
260             expect(@mani.model_name).to eq 'balloon'
261             expect(@mani.foreign_key).to eq 'speech_balloon_id'
262           end
263           it 'サポート機能が動作している' do
264             # モデルを再現できている
265             expect(@mani.model).to eq Balloon
266           end
267         end
268         describe 'speechに於いて' do
269           before do
270             @mani = @has_one['speech']
271           end
272           it 'マニフェストから設定を取り出している' do
273             # モデル名, 外部キーが定義あるいはデフォルト値補充されている
274             expect(@mani.model_name).to eq 'speech'
275             expect(@mani.foreign_key).to eq 'speech_balloon_id'
276           end
277           it 'サポート機能が動作している' do
278             # モデルを再現できている
279             expect(@mani.model).to eq Speech
280           end
281         end
282       end
283     end
284     
285     describe 'attributesに於いて' do
286       before do
287         @attributes = @model.my_manifest.attributes
288       end
289       it 'これらのカラムを定義している' do
290         set_attributes? @attributes, 
291           ['id', 'panel_id', 'speech_balloon_template_id', 'speech_balloon_template_module_name', 
292           'caption',  'speech_balloon_template_settings', 'z', 't', 
293           'created_at', 'updated_at']
294       end
295       describe 'panel_idに於いて' do
296         before do
297           @attribute = @attributes['panel_id']
298         end
299         it 'numberタイプである' do
300           expect(@attribute.type).to eq 'number'
301         end
302       end
303       describe 'speech_balloon_template_idに於いて' do
304         before do
305           @attribute = @attributes['speech_balloon_template_id']
306         end
307         it 'numberタイプである' do
308           expect(@attribute.type).to eq 'number'
309         end
310       end
311       describe 'speech_balloon_template_module_nameに於いて' do
312         before do
313           @attribute = @attributes['speech_balloon_template_module_name']
314         end
315         it 'textタイプである' do
316           expect(@attribute.type).to eq 'text'
317         end
318       end
319       describe 'captionに於いて' do
320         before do
321           @attribute = @attributes['caption']
322         end
323         it 'textタイプである' do
324           expect(@attribute.type).to eq 'text'
325         end
326       end
327       describe 'speech_balloon_template_settingsに於いて' do
328         before do
329           @attribute = @attributes['speech_balloon_template_settings']
330         end
331         it 'textタイプである' do
332           expect(@attribute.type).to eq 'text'
333         end
334       end
335       describe 'zに於いて' do
336         before do
337           @attribute = @attributes['z']
338         end
339         it 'numberタイプである' do
340           expect(@attribute.type).to eq 'number'
341         end
342       end
343       describe 'tに於いて' do
344         before do
345           @attribute = @attributes['t']
346         end
347         it 'numberタイプである' do
348           expect(@attribute.type).to eq 'number'
349         end
350       end
351     end
352     
353   end
354   
355 end