1 # -*- encoding: utf-8 -*-
4 describe SpeechBalloonTemplate do
5 include ManifestsMacros
7 @model = SpeechBalloonTemplate
10 describe 'ペタナイズに於いて' do
11 it 'スクコマを閉じるためのバインダーである' do
12 expect(@model.ancestors.include?(Peta::Binder)).to eq true
15 expect(@model.my_peta.parent_model_name).to be_blank
17 describe 'ブーストに於いて' do
19 expect(@model.my_peta.boost.keys).to be_empty
25 describe 'コントローラに於いて' do
27 @controller = @model.my_controller
29 it 'スクロールのためのコントローラである' do
30 expect(@model.item_name).to eq 'scroll'
32 describe 'actionに於いて' do
34 @actions = @controller.actions
35 @actions_names = ['index', 'by_author', 'by_panel', 'play', 'show',
36 'count', 'count_by_author', 'count_by_panel',
37 'new', 'edit', 'create', 'update', 'destroy']
39 it 'これらのアクションが定義されている' do
40 set_actions? @actions, @actions_names
42 describe 'baseに於いて' do
44 describe 'indexに於いて' do
46 @action = @actions['index']
48 it 'listタイプのアクションである' do
49 expect(@action.type).to eq 'list'
51 it 'マニフェストから設定を取り出している' do
52 # スクロールの公開リストを返すように定義している
53 set_list_action? @action, 'scroll', 'public'
56 describe 'by_authorに於いて' do
58 @action = @actions['by_author']
60 it 'listタイプのアクションである' do
61 expect(@action.type).to eq 'list'
63 it 'マニフェストから設定を取り出している' do
64 # スクロールの作家フィルタリストを返すように定義している
65 set_list_action? @action, 'scroll', 'by_author'
68 describe 'by_panelに於いて' do
70 @action = @actions['by_panel']
72 it 'listタイプのアクションである' do
73 expect(@action.type).to eq 'list'
75 it 'マニフェストから設定を取り出している' do
76 #スクロールのコマフィルタリストを返すように定義している
77 set_list_action? @action, 'scroll', 'by_panel'
80 describe 'countに於いて' do
82 @action = @actions['count']
84 it 'countタイプのアクションである' do
85 expect(@action.type).to eq 'count'
87 it 'マニフェストから設定を取り出している' do
88 #スクロールの公開リストのカウントを返すように定義している
89 set_list_action? @action, 'scroll', 'public'
92 describe 'count_by_authorに於いて' do
94 @action = @actions['count_by_author']
96 it 'countタイプのアクションである' do
97 expect(@action.type).to eq 'count'
99 it 'マニフェストから設定を取り出している' do
100 # スクロールの作家フィルタリストのカウントを返すように定義している
101 set_list_action? @action, 'scroll', 'by_author'
104 describe 'count_by_panelに於いて' do
106 @action = @actions['count_by_panel']
108 it 'countタイプのアクションである' do
109 expect(@action.type).to eq 'count'
111 it 'マニフェストから設定を取り出している' do
112 # スクロールのコマフィルタリストのカウントを返すように定義している
113 set_list_action? @action, 'scroll', 'by_panel'
116 describe 'newに於いて' do
118 @action = @actions['new']
120 it 'newタイプのアクションである' do
121 expect(@action.type).to eq 'new'
124 expect(@action.item_name).to eq 'scroll'
127 describe 'editに於いて' do
129 @action = @actions['edit']
131 it 'editタイプのアクションである' do
132 expect(@action.type).to eq 'edit'
135 expect(@action.item_name).to eq 'scroll'
138 describe 'createに於いて' do
140 @action = @actions['create']
142 it 'createタイプのアクションである' do
143 expect(@action.type).to eq 'create'
146 expect(@action.item_name).to eq 'scroll'
149 describe 'updateに於いて' do
151 @action = @actions['update']
153 it 'updateタイプのアクションである' do
154 expect(@action.type).to eq 'update'
157 expect(@action.item_name).to eq 'scroll'
160 describe 'destroyに於いて' do
162 @action = @actions['destroy']
164 it 'destroyタイプのアクションである' do
165 expect(@action.type).to eq 'destroy'
168 expect(@action.item_name).to eq 'scroll'
175 describe 'モデルに於いて' do
177 @my_manifest = @model.my_manifest
179 it 'サポート機能が動作している' do
180 expect(@my_manifest.model_name).to eq 'scroll'
181 expect(@my_manifest.classify).to eq @model
182 expect(@my_manifest.table_name).to eq 'scrolls'
185 describe 'associationsに於いて' do
186 describe 'belongs_toに於いて' do
188 @belongs_to = @my_manifest.associations.belongs_to
191 it 'これらのモデルに所属している' do
192 set_associations? @belongs_to, @names
194 describe 'authorに於いて' do
196 @mani = @belongs_to['author']
198 it 'マニフェストから設定を取り出している' do
199 # モデル名と外部キーが定義あるいはデフォルト値補充されている
200 expect(@mani.model_name).to eq 'author'
201 expect(@mani.id_column).to eq 'author_id'
203 it 'サポート機能が動作している' do
205 expect(@mani.model).to eq Author
209 describe 'has_manyに於いて' do
211 @has_many = @model.my_manifest.associations.has_many
212 @names = ['scroll_panels', 'panels']
214 it 'これらのモデルを所持している' do
215 set_associations? @has_many, @names
217 describe 'scroll_panelsに於いて' do
219 @mani = @has_many['scroll_panels']
221 it 'マニフェストから設定を取り出している' do
222 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
223 expect(@mani.model_name).to eq 'scroll_panel'
224 expect(@mani.foreign_key).to eq 'scroll_id'
225 expect(@mani.through).to be nil
227 it 'サポート機能が動作している' do
228 # モデルを再現できている, 中間モデルフラグ
229 expect(@mani.through?).to be false
230 expect(@mani.model).to eq ScrollPanel
233 describe 'panelsに於いて' do
235 @mani = @has_many['panels']
237 it 'マニフェストから設定を取り出している' do
238 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
239 expect(@mani.model_name).to eq 'panel'
240 expect(@mani.foreign_key).to eq 'scroll_id'
241 expect(@mani.through).to eq 'scroll_panels'
243 it 'サポート機能が動作している' do
244 # モデルを再現できている, 中間モデルフラグ
245 expect(@mani.through?).to be true
246 expect(@mani.model).to eq Panel
252 describe 'attributesに於いて' do
254 @attributes = @model.my_manifest.attributes
256 it 'これらのカラムを定義している' do
257 set_attributes? @attributes,
258 ['id', 'title', 'description', 'visible', 'author_id',
259 'created_at', 'updated_at']
261 describe 'titleに於いて' do
263 @attribute = @attributes['title']
266 expect(@attribute.type).to eq 'text'
269 describe 'descriptionに於いて' do
271 @attribute = @attributes['description']
274 expect(@attribute.type).to eq 'text'
277 describe 'visibleに於いて' do
279 @attribute = @attributes['visible']
282 expect(@attribute.type).to eq 'number'
284 it '選択肢を定数から取得できるように定義している' do
285 expect(@attribute.source.type).to eq 'magic_number'
286 expect(@attribute.source.select_item_name).to eq 'scroll_visible_items'
289 describe 'author_idに於いて' do
291 @attribute = @attributes['author_id']
294 expect(@attribute.type).to eq 'number'