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 'artist'
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, 'artist', '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, 'artist', 'public'
79 @action = @actions['new']
81 it 'newタイプのアクションである' do
82 expect(@action.type).to eq 'new'
85 expect(@action.item_name).to eq 'artist'
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 'artist'
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 'artist'
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 'artist'
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 'artist'
136 describe 'モデルに於いて' do
138 @my_manifest = @model.my_manifest
140 it 'サポート機能が動作している' do
141 expect(@my_manifest.model_name).to eq 'artist'
142 expect(@my_manifest.classify).to eq @model
143 expect(@my_manifest.table_name).to eq 'artists'
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 = ['resource_pictures']
161 it 'これらのモデルを所持している' do
162 set_associations? @has_many, @names
164 describe 'resource_picturesに於いて' do
166 @mani = @has_many['resource_pictures']
168 it 'マニフェストから設定を取り出している' do
169 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
170 expect(@mani.model_name).to eq 'resource_picture'
171 expect(@mani.foreign_key).to eq 'artist_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 ResourcePicture
183 describe 'attributesに於いて' do
185 @attributes = @model.my_manifest.attributes
187 it 'これらのカラムを定義している' do
188 set_attributes? @attributes,
189 ['id', 'name', 'user_id',
190 'created_at', 'updated_at']
192 describe 'nameに於いて' do
194 @attribute = @attributes['name']
197 expect(@attribute.type).to eq 'text'
200 describe 'user_idに於いて' do
202 @attribute = @attributes['user_id']
205 expect(@attribute.type).to eq 'number'