1 # -*- encoding: utf-8 -*-
5 describe WritingFormat do
6 include ManifestsMacros
11 describe 'ペタナイズに於いて' do
12 it 'フキダシを作るためのテンプレートである' do
13 expect(@model.ancestors.include?(Peta::Template)).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 'writing_format'
33 describe 'actionに於いて' do
35 @actions = @controller.actions
36 @actions_names = ['index', 'by_system_picture', 'show',
37 'count', 'count_by_system_picture',
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, 'writing_format', 'public'
57 describe 'by_system_pictureに於いて' do
59 @action = @actions['by_system_picture']
61 it 'listタイプのアクションである' do
62 expect(@action.type).to eq 'list'
64 it 'マニフェストから設定を取り出している' do
65 # 記法のシステム画像フィルタリストを返すように定義している
66 set_list_action? @action, 'writing_format', 'by_system_picture'
69 describe 'countに於いて' do
71 @action = @actions['count']
73 it 'countタイプのアクションである' do
74 expect(@action.type).to eq 'count'
76 it 'マニフェストから設定を取り出している' do
77 #記法の公開リストのカウントを返すように定義している
78 set_list_action? @action, 'writing_format', 'public'
81 describe 'showに於いて' do
83 @action = @actions['show']
85 it 'showタイプのアクションである' do
86 expect(@action.type).to eq 'show'
89 describe 'count_by_system_pictureに於いて' do
91 @action = @actions['count_by_system_picture']
93 it 'countタイプのアクションである' do
94 expect(@action.type).to eq 'count'
96 it 'マニフェストから設定を取り出している' do
97 # 記法のシステム画像フィルタリストのカウントを返すように定義している
98 set_list_action? @action, 'writing_format', 'by_system_picture'
101 describe 'newに於いて' do
103 @action = @actions['new']
105 it 'newタイプのアクションである' do
106 expect(@action.type).to eq 'new'
109 expect(@action.item_name).to eq 'writing_format'
112 describe 'editに於いて' do
114 @action = @actions['edit']
116 it 'editタイプのアクションである' do
117 expect(@action.type).to eq 'edit'
120 expect(@action.item_name).to eq 'writing_format'
123 describe 'createに於いて' do
125 @action = @actions['create']
127 it 'createタイプのアクションである' do
128 expect(@action.type).to eq 'create'
131 expect(@action.item_name).to eq 'writing_format'
134 describe 'updateに於いて' do
136 @action = @actions['update']
138 it 'updateタイプのアクションである' do
139 expect(@action.type).to eq 'update'
142 expect(@action.item_name).to eq 'writing_format'
145 describe 'destroyに於いて' do
147 @action = @actions['destroy']
149 it 'destroyタイプのアクションである' do
150 expect(@action.type).to eq 'destroy'
153 expect(@action.item_name).to eq 'writing_format'
160 describe 'モデルに於いて' do
162 @my_manifest = @model.my_manifest
164 it 'サポート機能が動作している' do
165 expect(@my_manifest.model_name).to eq 'writing_format'
166 expect(@my_manifest.classify).to eq @model
167 expect(@my_manifest.table_name).to eq 'writing_formats'
170 describe 'associationsに於いて' do
171 describe 'belongs_toに於いて' do
173 @belongs_to = @my_manifest.associations.belongs_to
174 @names = ['system_picture']
176 it 'これらのモデルに所属している' do
177 set_associations? @belongs_to, @names
179 describe 'system_pictureに於いて' do
181 @mani = @belongs_to['system_picture']
183 it 'マニフェストから設定を取り出している' do
184 # モデル名と外部キーが定義あるいはデフォルト値補充されている
185 expect(@mani.model_name).to eq 'system_picture'
186 expect(@mani.id_column).to eq 'system_picture_id'
188 it 'サポート機能が動作している' do
190 expect(@mani.model).to eq SystemPicture
194 describe 'has_manyに於いて' do
196 @has_many = @model.my_manifest.associations.has_many
197 @names = ['speeches']
199 it 'これらのモデルを所持している' do
200 set_associations? @has_many, @names
202 describe 'speechesに於いて' do
204 @mani = @has_many['speeches']
206 it 'マニフェストから設定を取り出している' do
207 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
208 expect(@mani.model_name).to eq 'speech'
209 expect(@mani.foreign_key).to eq 'writing_format_id'
210 expect(@mani.through).to be nil
212 it 'サポート機能が動作している' do
213 # モデルを再現できている, 中間モデルフラグ
214 expect(@mani.through?).to be false
215 expect(@mani.model).to eq Speech
221 describe 'attributesに於いて' do
223 @attributes = @model.my_manifest.attributes
225 it 'これらのカラムを定義している' do
226 set_attributes? @attributes,
227 ['id', 'name', 'module_name', 'caption', 'system_picture_id', 'settings',
228 'created_at', 'updated_at']
230 describe 'nameに於いて' do
232 @attribute = @attributes['name']
235 expect(@attribute.type).to eq 'text'
238 describe 'module_nameに於いて' do
240 @attribute = @attributes['module_name']
243 expect(@attribute.type).to eq 'text'
246 describe 'captionに於いて' do
248 @attribute = @attributes['caption']
251 expect(@attribute.type).to eq 'text'
254 describe 'system_picture_idに於いて' do
256 @attribute = @attributes['system_picture_id']
259 expect(@attribute.type).to eq 'number'
262 describe 'settingsに於いて' do
264 @attribute = @attributes['settings']
267 expect(@attribute.type).to eq 'text'