1 # -*- encoding: utf-8 -*-
6 include ManifestsMacros
11 describe 'ペタナイズに於いて' do
12 it 'スト紙を閉じるためのバインダーである' do
13 expect(@model.ancestors.include?(Peta::Binder)).to eq true
16 expect(@model.my_peta.parent_model_name).to be_blank
18 describe 'ブーストに於いて' do
20 expect(@model.my_peta.boost.keys).to be_empty
26 describe 'コントローラに於いて' do
28 @controller = @model.my_controller
30 it 'ストーリーのためのコントローラである' do
31 expect(@model.item_name).to eq 'story'
33 describe 'actionに於いて' do
35 @actions = @controller.actions
36 @actions_names = ['index', 'by_author', 'by_comic', 'by_sheet', 'play', 'show',
37 'count', 'count_by_author', 'count_by_comic', 'count_by_sheet',
38 'new', 'edit', 'create', 'update', 'destroy']
40 it 'これらのアクションが定義されている' do
41 set_actions? @actions, @actions_names
43 describe 'baseに於いて' do
45 describe 'indexに於いて' do
47 @action = @actions['index']
49 it 'listタイプのアクションである' do
50 expect(@action.type).to eq 'list'
52 it 'マニフェストから設定を取り出している' do
53 # ストーリーの公開リストを返すように定義している
54 set_list_action? @action, 'story', 'public'
57 describe 'by_authorに於いて' do
59 @action = @actions['by_author']
61 it 'listタイプのアクションである' do
62 expect(@action.type).to eq 'list'
64 it 'マニフェストから設定を取り出している' do
65 # ストーリーの作家フィルタリストを返すように定義している
66 set_list_action? @action, 'story', 'by_author'
69 describe 'by_comicに於いて' do
71 @action = @actions['by_comic']
73 it 'listタイプのアクションである' do
74 expect(@action.type).to eq 'list'
76 it 'マニフェストから設定を取り出している' do
77 #ストーリーのコマフィルタリストを返すように定義している
78 set_list_action? @action, 'story', 'by_comic'
81 describe 'by_sheetに於いて' do
83 @action = @actions['by_sheet']
85 it 'listタイプのアクションである' do
86 expect(@action.type).to eq 'list'
88 it 'マニフェストから設定を取り出している' do
89 #ストーリーのコマフィルタリストを返すように定義している
90 set_list_action? @action, 'story', 'by_sheet'
93 describe 'showに於いて' do
95 @action = @actions['show']
97 it 'showタイプのアクションである' do
98 expect(@action.type).to eq 'show'
101 describe 'countに於いて' do
103 @action = @actions['count']
105 it 'countタイプのアクションである' do
106 expect(@action.type).to eq 'count'
108 it 'マニフェストから設定を取り出している' do
109 #ストーリーの公開リストのカウントを返すように定義している
110 set_list_action? @action, 'story', 'public'
113 describe 'count_by_authorに於いて' do
115 @action = @actions['count_by_author']
117 it 'countタイプのアクションである' do
118 expect(@action.type).to eq 'count'
120 it 'マニフェストから設定を取り出している' do
121 # ストーリーの作家フィルタリストのカウントを返すように定義している
122 set_list_action? @action, 'story', 'by_author'
125 describe 'count_by_comicに於いて' do
127 @action = @actions['count_by_comic']
129 it 'countタイプのアクションである' do
130 expect(@action.type).to eq 'count'
132 it 'マニフェストから設定を取り出している' do
133 # ストーリーのコマフィルタリストのカウントを返すように定義している
134 set_list_action? @action, 'story', 'by_comic'
137 describe 'count_by_sheetに於いて' do
139 @action = @actions['count_by_sheet']
141 it 'countタイプのアクションである' do
142 expect(@action.type).to eq 'count'
144 it 'マニフェストから設定を取り出している' do
145 # ストーリーのコマフィルタリストのカウントを返すように定義している
146 set_list_action? @action, 'story', 'by_sheet'
149 describe 'newに於いて' do
151 @action = @actions['new']
153 it 'newタイプのアクションである' do
154 expect(@action.type).to eq 'new'
157 expect(@action.item_name).to eq 'story'
160 describe 'editに於いて' do
162 @action = @actions['edit']
164 it 'editタイプのアクションである' do
165 expect(@action.type).to eq 'edit'
168 expect(@action.item_name).to eq 'story'
171 describe 'createに於いて' do
173 @action = @actions['create']
175 it 'createタイプのアクションである' do
176 expect(@action.type).to eq 'create'
179 expect(@action.item_name).to eq 'story'
182 describe 'updateに於いて' do
184 @action = @actions['update']
186 it 'updateタイプのアクションである' do
187 expect(@action.type).to eq 'update'
190 expect(@action.item_name).to eq 'story'
193 describe 'destroyに於いて' do
195 @action = @actions['destroy']
197 it 'destroyタイプのアクションである' do
198 expect(@action.type).to eq 'destroy'
201 expect(@action.item_name).to eq 'story'
208 describe 'モデルに於いて' do
210 @my_manifest = @model.my_manifest
212 it 'サポート機能が動作している' do
213 expect(@my_manifest.model_name).to eq 'story'
214 expect(@my_manifest.classify).to eq @model
215 expect(@my_manifest.table_name).to eq 'stories'
218 describe 'associationsに於いて' do
219 describe 'belongs_toに於いて' do
221 @belongs_to = @my_manifest.associations.belongs_to
224 it 'これらのモデルに所属している' do
225 set_associations? @belongs_to, @names
227 describe 'authorに於いて' do
229 @mani = @belongs_to['author']
231 it 'マニフェストから設定を取り出している' do
232 # モデル名と外部キーが定義あるいはデフォルト値補充されている
233 expect(@mani.model_name).to eq 'author'
234 expect(@mani.id_column).to eq 'author_id'
236 it 'サポート機能が動作している' do
238 expect(@mani.model).to eq Author
242 describe 'has_manyに於いて' do
244 @has_many = @model.my_manifest.associations.has_many
245 @names = ['comic_stories', 'comics', 'comic_stories', 'comics']
247 it 'これらのモデルを所持している' do
248 set_associations? @has_many, @names
250 describe 'comic_storiesに於いて' do
252 @mani = @has_many['comic_stories']
254 it 'マニフェストから設定を取り出している' do
255 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
256 expect(@mani.model_name).to eq 'comic_story'
257 expect(@mani.foreign_key).to eq 'story_id'
258 expect(@mani.through).to be nil
260 it 'サポート機能が動作している' do
261 # モデルを再現できている, 中間モデルフラグ
262 expect(@mani.through?).to be false
263 expect(@mani.model).to eq ComicStory
266 describe 'comicsに於いて' do
268 @mani = @has_many['comics']
270 it 'マニフェストから設定を取り出している' do
271 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
272 expect(@mani.model_name).to eq 'comic'
273 expect(@mani.foreign_key).to eq 'story_id'
274 expect(@mani.through).to eq 'comic_stories'
276 it 'サポート機能が動作している' do
277 # モデルを再現できている, 中間モデルフラグ
278 expect(@mani.through?).to be true
279 expect(@mani.model).to eq Comic
282 describe 'story_sheetsに於いて' do
284 @mani = @has_many['story_sheets']
286 it 'マニフェストから設定を取り出している' do
287 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
288 expect(@mani.model_name).to eq 'story_sheet'
289 expect(@mani.foreign_key).to eq 'story_id'
290 expect(@mani.through).to be nil
292 it 'サポート機能が動作している' do
293 # モデルを再現できている, 中間モデルフラグ
294 expect(@mani.through?).to be false
295 expect(@mani.model).to eq StorySheet
298 describe 'sheetsに於いて' do
300 @mani = @has_many['sheets']
302 it 'マニフェストから設定を取り出している' do
303 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
304 expect(@mani.model_name).to eq 'sheet'
305 expect(@mani.foreign_key).to eq 'story_id'
306 expect(@mani.through).to eq 'story_sheets'
308 it 'サポート機能が動作している' do
309 # モデルを再現できている, 中間モデルフラグ
310 expect(@mani.through?).to be true
311 expect(@mani.model).to eq Sheet
317 describe 'attributesに於いて' do
319 @attributes = @model.my_manifest.attributes
321 it 'これらのカラムを定義している' do
322 set_attributes? @attributes,
323 ['id', 'title', 'description', 'visible', 't', 'author_id',
324 'created_at', 'updated_at']
326 describe 'titleに於いて' do
328 @attribute = @attributes['title']
331 expect(@attribute.type).to eq 'text'
334 describe 'descriptionに於いて' do
336 @attribute = @attributes['description']
339 expect(@attribute.type).to eq 'text'
344 @attribute = @attributes['t']
347 expect(@attribute.type).to eq 'number'
350 describe 'visibleに於いて' do
352 @attribute = @attributes['visible']
355 expect(@attribute.type).to eq 'number'
357 it '選択肢を定数から取得できるように定義している' do
358 expect(@attribute.source.type).to eq 'magic_number'
359 expect(@attribute.source.select_item_name).to eq 'story_visible_items'
362 describe 'author_idに於いて' do
364 @attribute = @attributes['author_id']
367 expect(@attribute.type).to eq 'number'