1 # -*- encoding: utf-8 -*-
5 describe WritingFormat do
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 'scroll'
33 describe 'actionに於いて' do
35 @actions = @controller.actions
36 @actions_names = ['index', 'by_author', 'by_panel', 'play', 'show',
37 'count', 'count_by_author', 'count_by_panel',
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, 'scroll', '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, 'scroll', 'by_author'
69 describe 'by_panelに於いて' do
71 @action = @actions['by_panel']
73 it 'listタイプのアクションである' do
74 expect(@action.type).to eq 'list'
76 it 'マニフェストから設定を取り出している' do
77 #スクロールのコマフィルタリストを返すように定義している
78 set_list_action? @action, 'scroll', 'by_panel'
81 describe 'countに於いて' do
83 @action = @actions['count']
85 it 'countタイプのアクションである' do
86 expect(@action.type).to eq 'count'
88 it 'マニフェストから設定を取り出している' do
89 #スクロールの公開リストのカウントを返すように定義している
90 set_list_action? @action, 'scroll', 'public'
93 describe 'count_by_authorに於いて' do
95 @action = @actions['count_by_author']
97 it 'countタイプのアクションである' do
98 expect(@action.type).to eq 'count'
100 it 'マニフェストから設定を取り出している' do
101 # スクロールの作家フィルタリストのカウントを返すように定義している
102 set_list_action? @action, 'scroll', 'by_author'
105 describe 'count_by_panelに於いて' do
107 @action = @actions['count_by_panel']
109 it 'countタイプのアクションである' do
110 expect(@action.type).to eq 'count'
112 it 'マニフェストから設定を取り出している' do
113 # スクロールのコマフィルタリストのカウントを返すように定義している
114 set_list_action? @action, 'scroll', 'by_panel'
117 describe 'newに於いて' do
119 @action = @actions['new']
121 it 'newタイプのアクションである' do
122 expect(@action.type).to eq 'new'
125 expect(@action.item_name).to eq 'scroll'
128 describe 'editに於いて' do
130 @action = @actions['edit']
132 it 'editタイプのアクションである' do
133 expect(@action.type).to eq 'edit'
136 expect(@action.item_name).to eq 'scroll'
139 describe 'createに於いて' do
141 @action = @actions['create']
143 it 'createタイプのアクションである' do
144 expect(@action.type).to eq 'create'
147 expect(@action.item_name).to eq 'scroll'
150 describe 'updateに於いて' do
152 @action = @actions['update']
154 it 'updateタイプのアクションである' do
155 expect(@action.type).to eq 'update'
158 expect(@action.item_name).to eq 'scroll'
161 describe 'destroyに於いて' do
163 @action = @actions['destroy']
165 it 'destroyタイプのアクションである' do
166 expect(@action.type).to eq 'destroy'
169 expect(@action.item_name).to eq 'scroll'
176 describe 'モデルに於いて' do
178 @my_manifest = @model.my_manifest
180 it 'サポート機能が動作している' do
181 expect(@my_manifest.model_name).to eq 'scroll'
182 expect(@my_manifest.classify).to eq @model
183 expect(@my_manifest.table_name).to eq 'scrolls'
186 describe 'associationsに於いて' do
187 describe 'belongs_toに於いて' do
189 @belongs_to = @my_manifest.associations.belongs_to
192 it 'これらのモデルに所属している' do
193 set_associations? @belongs_to, @names
195 describe 'authorに於いて' do
197 @mani = @belongs_to['author']
199 it 'マニフェストから設定を取り出している' do
200 # モデル名と外部キーが定義あるいはデフォルト値補充されている
201 expect(@mani.model_name).to eq 'author'
202 expect(@mani.id_column).to eq 'author_id'
204 it 'サポート機能が動作している' do
206 expect(@mani.model).to eq Author
210 describe 'has_manyに於いて' do
212 @has_many = @model.my_manifest.associations.has_many
213 @names = ['scroll_panels', 'panels']
215 it 'これらのモデルを所持している' do
216 set_associations? @has_many, @names
218 describe 'scroll_panelsに於いて' do
220 @mani = @has_many['scroll_panels']
222 it 'マニフェストから設定を取り出している' do
223 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
224 expect(@mani.model_name).to eq 'scroll_panel'
225 expect(@mani.foreign_key).to eq 'scroll_id'
226 expect(@mani.through).to be nil
228 it 'サポート機能が動作している' do
229 # モデルを再現できている, 中間モデルフラグ
230 expect(@mani.through?).to be false
231 expect(@mani.model).to eq ScrollPanel
234 describe 'panelsに於いて' do
236 @mani = @has_many['panels']
238 it 'マニフェストから設定を取り出している' do
239 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
240 expect(@mani.model_name).to eq 'panel'
241 expect(@mani.foreign_key).to eq 'scroll_id'
242 expect(@mani.through).to eq 'scroll_panels'
244 it 'サポート機能が動作している' do
245 # モデルを再現できている, 中間モデルフラグ
246 expect(@mani.through?).to be true
247 expect(@mani.model).to eq Panel
253 describe 'attributesに於いて' do
255 @attributes = @model.my_manifest.attributes
257 it 'これらのカラムを定義している' do
258 set_attributes? @attributes,
259 ['id', 'title', 'description', 'visible', 'author_id',
260 'created_at', 'updated_at']
262 describe 'titleに於いて' do
264 @attribute = @attributes['title']
267 expect(@attribute.type).to eq 'text'
270 describe 'descriptionに於いて' do
272 @attribute = @attributes['description']
275 expect(@attribute.type).to eq 'text'
278 describe 'visibleに於いて' do
280 @attribute = @attributes['visible']
283 expect(@attribute.type).to eq 'number'
285 it '選択肢を定数から取得できるように定義している' do
286 expect(@attribute.source.type).to eq 'magic_number'
287 expect(@attribute.source.select_item_name).to eq 'scroll_visible_items'
290 describe 'author_idに於いて' do
292 @attribute = @attributes['author_id']
295 expect(@attribute.type).to eq 'number'