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 '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 'showに於いて' do
83 @action = @actions['show']
85 it 'showタイプのアクションである' do
86 expect(@action.type).to eq 'show'
89 describe 'countに於いて' do
91 @action = @actions['count']
93 it 'countタイプのアクションである' do
94 expect(@action.type).to eq 'count'
96 it 'マニフェストから設定を取り出している' do
97 #スクロールの公開リストのカウントを返すように定義している
98 set_list_action? @action, 'scroll', 'public'
101 describe 'count_by_authorに於いて' do
103 @action = @actions['count_by_author']
105 it 'countタイプのアクションである' do
106 expect(@action.type).to eq 'count'
108 it 'マニフェストから設定を取り出している' do
109 # スクロールの作家フィルタリストのカウントを返すように定義している
110 set_list_action? @action, 'scroll', 'by_author'
113 describe 'count_by_panelに於いて' do
115 @action = @actions['count_by_panel']
117 it 'countタイプのアクションである' do
118 expect(@action.type).to eq 'count'
120 it 'マニフェストから設定を取り出している' do
121 # スクロールのコマフィルタリストのカウントを返すように定義している
122 set_list_action? @action, 'scroll', 'by_panel'
125 describe 'newに於いて' do
127 @action = @actions['new']
129 it 'newタイプのアクションである' do
130 expect(@action.type).to eq 'new'
133 expect(@action.item_name).to eq 'scroll'
136 describe 'editに於いて' do
138 @action = @actions['edit']
140 it 'editタイプのアクションである' do
141 expect(@action.type).to eq 'edit'
144 expect(@action.item_name).to eq 'scroll'
147 describe 'createに於いて' do
149 @action = @actions['create']
151 it 'createタイプのアクションである' do
152 expect(@action.type).to eq 'create'
155 expect(@action.item_name).to eq 'scroll'
158 describe 'updateに於いて' do
160 @action = @actions['update']
162 it 'updateタイプのアクションである' do
163 expect(@action.type).to eq 'update'
166 expect(@action.item_name).to eq 'scroll'
169 describe 'destroyに於いて' do
171 @action = @actions['destroy']
173 it 'destroyタイプのアクションである' do
174 expect(@action.type).to eq 'destroy'
177 expect(@action.item_name).to eq 'scroll'
184 describe 'モデルに於いて' do
186 @my_manifest = @model.my_manifest
188 it 'サポート機能が動作している' do
189 expect(@my_manifest.model_name).to eq 'scroll'
190 expect(@my_manifest.classify).to eq @model
191 expect(@my_manifest.table_name).to eq 'scrolls'
194 describe 'associationsに於いて' do
195 describe 'belongs_toに於いて' do
197 @belongs_to = @my_manifest.associations.belongs_to
200 it 'これらのモデルに所属している' do
201 set_associations? @belongs_to, @names
203 describe 'authorに於いて' do
205 @mani = @belongs_to['author']
207 it 'マニフェストから設定を取り出している' do
208 # モデル名と外部キーが定義あるいはデフォルト値補充されている
209 expect(@mani.model_name).to eq 'author'
210 expect(@mani.id_column).to eq 'author_id'
212 it 'サポート機能が動作している' do
214 expect(@mani.model).to eq Author
218 describe 'has_manyに於いて' do
220 @has_many = @model.my_manifest.associations.has_many
221 @names = ['scroll_panels', 'panels']
223 it 'これらのモデルを所持している' do
224 set_associations? @has_many, @names
226 describe 'scroll_panelsに於いて' do
228 @mani = @has_many['scroll_panels']
230 it 'マニフェストから設定を取り出している' do
231 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
232 expect(@mani.model_name).to eq 'scroll_panel'
233 expect(@mani.foreign_key).to eq 'scroll_id'
234 expect(@mani.through).to be nil
236 it 'サポート機能が動作している' do
237 # モデルを再現できている, 中間モデルフラグ
238 expect(@mani.through?).to be false
239 expect(@mani.model).to eq ScrollPanel
242 describe 'panelsに於いて' do
244 @mani = @has_many['panels']
246 it 'マニフェストから設定を取り出している' do
247 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
248 expect(@mani.model_name).to eq 'panel'
249 expect(@mani.foreign_key).to eq 'scroll_id'
250 expect(@mani.through).to eq 'scroll_panels'
252 it 'サポート機能が動作している' do
253 # モデルを再現できている, 中間モデルフラグ
254 expect(@mani.through?).to be true
255 expect(@mani.model).to eq Panel
261 describe 'attributesに於いて' do
263 @attributes = @model.my_manifest.attributes
265 it 'これらのカラムを定義している' do
266 set_attributes? @attributes,
267 ['id', 'title', 'description', 'visible', 'author_id',
268 'created_at', 'updated_at']
270 describe 'titleに於いて' do
272 @attribute = @attributes['title']
275 expect(@attribute.type).to eq 'text'
278 describe 'descriptionに於いて' do
280 @attribute = @attributes['description']
283 expect(@attribute.type).to eq 'text'
286 describe 'visibleに於いて' do
288 @attribute = @attributes['visible']
291 expect(@attribute.type).to eq 'number'
293 it '選択肢を定数から取得できるように定義している' do
294 expect(@attribute.source.type).to eq 'magic_number'
295 expect(@attribute.source.select_item_name).to eq 'scroll_visible_items'
298 describe 'author_idに於いて' do
300 @attribute = @attributes['author_id']
303 expect(@attribute.type).to eq 'number'