OSDN Git Service

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