1 # -*- encoding: utf-8 -*-
\r
3 require 'spec_helper'
\r
6 include ManifestsMacros
\r
11 describe 'ペタナイズに於いて' do
\r
12 it 'フキダシの要素として利用されるエレメントである' do
\r
13 expect(@model.ancestors.include?(Peta::Element)).to eq true
\r
15 it '親モデルはフキダシである' do
\r
16 expect(@model.my_peta.parent_model_name).to eq 'speech_balloon'
\r
18 describe 'ブーストに於いて' do
\r
20 @boosts = @model.my_peta.boost
\r
21 @boosts_names = ['speech_balloon_template', 'writing_format']
\r
23 it 'これらのブーストが定義されている' do
\r
24 set_boosts? @boosts, @boosts_names
\r
26 describe 'フキダシテンプレートに於いて' do
\r
28 @mani = @boosts['speech_balloon_template']
\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
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
45 describe '記法に於いて' do
\r
47 @mani = @boosts['writing_format']
\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
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
68 describe 'コントローラに於いて' do
\r
70 @controller = @model.my_controller
\r
72 it 'セリフのためのコントローラである' do
\r
73 expect(@model.item_name).to eq 'speech'
\r
75 describe 'actionに於いて' do
\r
77 @actions = @controller.actions
\r
78 @actions_names = ['index', 'by_author', 'show',
\r
79 'count', 'count_by_author',
\r
82 it 'これらのアクションが定義されている' do
\r
83 set_actions? @actions, @actions_names
\r
85 describe 'baseに於いて' do
\r
87 describe 'indexに於いて' do
\r
89 @action = @actions['index']
\r
91 it 'listタイプのアクションである' do
\r
92 expect(@action.type).to eq 'list'
\r
94 it 'マニフェストから設定を取り出している' do
\r
95 # セリフの公開リストを返すように定義している
\r
96 set_list_action? @action, 'speech', 'public'
\r
99 describe 'by_authorに於いて' do
\r
101 @action = @actions['by_author']
\r
103 it 'listタイプのアクションである' do
\r
104 expect(@action.type).to eq 'list'
\r
106 it 'マニフェストから設定を取り出している' do
\r
107 # セリフの作家フィルタリストを返すように定義している
\r
108 set_list_action? @action, 'speech', 'by_author'
\r
111 describe 'countに於いて' do
\r
113 @action = @actions['count']
\r
115 it 'countタイプのアクションである' do
\r
116 expect(@action.type).to eq 'count'
\r
118 it 'マニフェストから設定を取り出している' do
\r
119 #セリフの公開リストのカウントを返すように定義している
\r
120 set_list_action? @action, 'speech', 'public'
\r
123 describe 'count_by_authorに於いて' do
\r
125 @action = @actions['count_by_author']
\r
127 it 'countタイプのアクションである' do
\r
128 expect(@action.type).to eq 'count'
\r
130 it 'マニフェストから設定を取り出している' do
\r
131 # セリフの作家フィルタリストのカウントを返すように定義している
\r
132 set_list_action? @action, 'speech', 'by_author'
\r
135 describe 'newに於いて' do
\r
137 @action = @actions['new']
\r
139 it 'newタイプのアクションである' do
\r
140 expect(@action.type).to eq 'new'
\r
143 expect(@action.item_name).to eq 'speech'
\r
146 describe 'editに於いて' do
\r
148 @action = @actions['edit']
\r
150 it 'editタイプのアクションである' do
\r
151 expect(@action.type).to eq 'edit'
\r
154 expect(@action.item_name).to eq 'speech'
\r
161 describe 'モデルに於いて' do
\r
163 @my_manifest = @model.my_manifest
\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
171 describe 'associationsに於いて' do
\r
172 describe 'belongs_toに於いて' do
\r
174 @belongs_to = @my_manifest.associations.belongs_to
\r
175 @names = ['speech_balloon', 'writing_format', 'speech_balloon_template']
\r
177 it 'これらのモデルに所属している' do
\r
178 set_associations? @belongs_to, @names
\r
180 describe 'speech_balloonに於いて' do
\r
182 @mani = @belongs_to['speech_balloon']
\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
189 it 'サポート機能が動作している' do
\r
191 expect(@mani.model).to eq SpeechBalloon
\r
194 describe 'writing_formatに於いて' do
\r
196 @mani = @belongs_to['writing_format']
\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
203 it 'サポート機能が動作している' do
\r
205 expect(@mani.model).to eq WritingFormat
\r
208 describe 'speech_balloon_templateに於いて' do
\r
210 @mani = @belongs_to['speech_balloon_template']
\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
217 it 'サポート機能が動作している' do
\r
219 expect(@mani.model).to eq SpeechBalloonTemplate
\r
223 describe 'has_manyに於いて' do
\r
225 @has_many = @model.my_manifest.associations.has_many
\r
228 it 'これらのモデルを所持している' do
\r
229 set_associations? @has_many, @names
\r
234 describe 'attributesに於いて' do
\r
236 @attributes = @model.my_manifest.attributes
\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
247 describe 'speech_balloon_idに於いて' do
\r
249 @attribute = @attributes['speech_balloon_id']
\r
251 it 'numberタイプである' do
\r
252 expect(@attribute.type).to eq 'number'
\r
255 describe 'speech_balloon_template_idに於いて' do
\r
257 @attribute = @attributes['speech_balloon_template_id']
\r
259 it 'numberタイプである' do
\r
260 expect(@attribute.type).to eq 'number'
\r
263 describe 'speech_balloon_template_module_nameに於いて' do
\r
265 @attribute = @attributes['speech_balloon_template_module_name']
\r
268 expect(@attribute.type).to eq 'text'
\r
271 describe 'writing_format_idに於いて' do
\r
273 @attribute = @attributes['writing_format_id']
\r
275 it 'numberタイプである' do
\r
276 expect(@attribute.type).to eq 'number'
\r
279 describe 'writing_format_module_nameに於いて' do
\r
281 @attribute = @attributes['writing_format_module_name']
\r
284 expect(@attribute.type).to eq 'text'
\r
287 describe 'contentに於いて' do
\r
289 @attribute = @attributes['content']
\r
292 expect(@attribute.type).to eq 'text'
\r
295 describe 'font_sizeに於いて' do
\r
297 @attribute = @attributes['font_size']
\r
299 it 'numberタイプである' do
\r
300 expect(@attribute.type).to eq 'float'
\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
307 describe 'text_alignに於いて' do
\r
309 @attribute = @attributes['text_align']
\r
311 it 'numberタイプである' do
\r
312 expect(@attribute.type).to eq 'number'
\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
319 describe 'fore_colorに於いて' do
\r
321 @attribute = @attributes['fore_color']
\r
323 it 'numberタイプである' do
\r
324 expect(@attribute.type).to eq 'number'
\r
327 describe 'xに於いて' do
\r
329 @attribute = @attributes['x']
\r
331 it 'numberタイプである' do
\r
332 expect(@attribute.type).to eq 'number'
\r
335 describe 'yに於いて' do
\r
337 @attribute = @attributes['y']
\r
339 it 'numberタイプである' do
\r
340 expect(@attribute.type).to eq 'number'
\r
343 describe 'widthに於いて' do
\r
345 @attribute = @attributes['width']
\r
347 it 'numberタイプである' do
\r
348 expect(@attribute.type).to eq 'number'
\r
351 describe 'heightに於いて' do
\r
353 @attribute = @attributes['height']
\r
355 it 'numberタイプである' do
\r
356 expect(@attribute.type).to eq 'number'
\r
359 describe 'quotesに於いて' do
\r
361 @attribute = @attributes['quotes']
\r
364 expect(@attribute.type).to eq 'text'
\r
367 describe 'speech_balloon_template_settingsに於いて' do
\r
369 @attribute = @attributes['speech_balloon_template_settings']
\r
372 expect(@attribute.type).to eq 'text'
\r
375 describe 'writing_format_settingsに於いて' do
\r
377 @attribute = @attributes['writing_format_settings']
\r
380 expect(@attribute.type).to eq 'text'
\r