1 # -*- encoding: utf-8 -*-
6 include ManifestsMacros
11 describe 'ペタナイズに於いて' do
13 expect(@model.ancestors.include?(Peta::Owner)).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 'author'
33 describe 'actionに於いて' do
35 @actions = @controller.actions
36 @actions_names = ['index', 'show',
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, 'author', 'public'
57 describe 'showに於いて' do
59 @action = @actions['show']
61 it 'showタイプのアクションである' do
62 expect(@action.type).to eq 'show'
65 describe 'countに於いて' do
67 @action = @actions['count']
69 it 'countタイプのアクションである' do
70 expect(@action.type).to eq 'count'
72 it 'マニフェストから設定を取り出している' do
73 #作家の公開リストのカウントを返すように定義している
74 set_list_action? @action, 'author', 'public'
79 @action = @actions['new']
81 it 'newタイプのアクションである' do
82 expect(@action.type).to eq 'new'
85 expect(@action.item_name).to eq 'author'
88 describe 'editに於いて' do
90 @action = @actions['edit']
92 it 'editタイプのアクションである' do
93 expect(@action.type).to eq 'edit'
96 expect(@action.item_name).to eq 'author'
99 describe 'createに於いて' do
101 @action = @actions['create']
103 it 'createタイプのアクションである' do
104 expect(@action.type).to eq 'create'
107 expect(@action.item_name).to eq 'author'
110 describe 'updateに於いて' do
112 @action = @actions['update']
114 it 'updateタイプのアクションである' do
115 expect(@action.type).to eq 'update'
118 expect(@action.item_name).to eq 'author'
121 describe 'destroyに於いて' do
123 @action = @actions['destroy']
125 it 'destroyタイプのアクションである' do
126 expect(@action.type).to eq 'destroy'
129 expect(@action.item_name).to eq 'author'
136 describe 'モデルに於いて' do
138 @my_manifest = @model.my_manifest
140 it 'サポート機能が動作している' do
141 expect(@my_manifest.model_name).to eq 'author'
142 expect(@my_manifest.classify).to eq @model
143 expect(@my_manifest.table_name).to eq 'authors'
146 describe 'associationsに於いて' do
147 describe 'belongs_toに於いて' do
149 @belongs_to = @my_manifest.associations.belongs_to
152 it 'これらのモデルに所属している' do
153 set_associations? @belongs_to, @names
156 describe 'has_manyに於いて' do
158 @has_many = @model.my_manifest.associations.has_many
159 @names = ['scrolls', 'comics', 'stories', 'sheets', 'panels']
161 it 'これらのモデルを所持している' do
162 set_associations? @has_many, @names
164 describe 'scrollsに於いて' do
166 @mani = @has_many['scrolls']
168 it 'マニフェストから設定を取り出している' do
169 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
170 expect(@mani.model_name).to eq 'scroll'
171 expect(@mani.foreign_key).to eq 'author_id'
172 expect(@mani.through).to be nil
174 it 'サポート機能が動作している' do
175 # モデルを再現できている, 中間モデルフラグ
176 expect(@mani.through?).to be false
177 expect(@mani.model).to eq Scroll
180 describe 'comicsに於いて' do
182 @mani = @has_many['comics']
184 it 'マニフェストから設定を取り出している' do
185 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
186 expect(@mani.model_name).to eq 'comic'
187 expect(@mani.foreign_key).to eq 'author_id'
188 expect(@mani.through).to be nil
190 it 'サポート機能が動作している' do
191 # モデルを再現できている, 中間モデルフラグ
192 expect(@mani.through?).to be false
193 expect(@mani.model).to eq Comic
196 describe 'storiesに於いて' do
198 @mani = @has_many['stories']
200 it 'マニフェストから設定を取り出している' do
201 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
202 expect(@mani.model_name).to eq 'story'
203 expect(@mani.foreign_key).to eq 'author_id'
204 expect(@mani.through).to be nil
206 it 'サポート機能が動作している' do
207 # モデルを再現できている, 中間モデルフラグ
208 expect(@mani.through?).to be false
209 expect(@mani.model).to eq Story
212 describe 'sheetsに於いて' do
214 @mani = @has_many['sheets']
216 it 'マニフェストから設定を取り出している' do
217 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
218 expect(@mani.model_name).to eq 'sheet'
219 expect(@mani.foreign_key).to eq 'author_id'
220 expect(@mani.through).to be nil
222 it 'サポート機能が動作している' do
223 # モデルを再現できている, 中間モデルフラグ
224 expect(@mani.through?).to be false
225 expect(@mani.model).to eq Sheet
228 describe 'panelsに於いて' do
230 @mani = @has_many['panels']
232 it 'マニフェストから設定を取り出している' do
233 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
234 expect(@mani.model_name).to eq 'panel'
235 expect(@mani.foreign_key).to eq 'author_id'
236 expect(@mani.through).to be nil
238 it 'サポート機能が動作している' do
239 # モデルを再現できている, 中間モデルフラグ
240 expect(@mani.through?).to be false
241 expect(@mani.model).to eq Panel
247 describe 'attributesに於いて' do
249 @attributes = @model.my_manifest.attributes
251 it 'これらのカラムを定義している' do
252 set_attributes? @attributes,
253 ['id', 'name', 'user_id',
254 'created_at', 'updated_at']
256 describe 'nameに於いて' do
258 @attribute = @attributes['name']
261 expect(@attribute.type).to eq 'text'
264 describe 'author_idに於いて' do
266 @attribute = @attributes['user_id']
269 expect(@attribute.type).to eq 'number'