OSDN Git Service

fix:error dlg
[pettanr/pettanr.git] / spec / manifests / writing_format_spec.rb
1 # -*- encoding: utf-8 -*-
2 require 'spec_helper'
3 #シ 
4
5 describe WritingFormat do
6   include ManifestsMacros
7   before do
8     @model = WritingFormat
9   end
10   
11   describe 'ペタナイズに於いて' do
12     it 'フキダシを作るためのテンプレートである' do
13       expect(@model.ancestors.include?(Peta::Template)).to eq true
14     end
15     it '親モデルは持たない' do
16       expect(@model.my_peta.parent_model_name).to be_blank
17     end
18     describe 'ブーストに於いて' do
19       it '特筆すべき注意事項はない' do
20         expect(@model.my_peta.boost.keys).to be_empty
21       end
22     end
23     
24   end
25   
26   describe 'コントローラに於いて' do
27     before do
28       @controller = @model.my_controller
29     end
30     it '記法のためのコントローラである' do
31       expect(@model.item_name).to eq 'writing_format'
32     end
33     describe 'actionに於いて' do
34       before 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']
39       end
40       it 'これらのアクションが定義されている' do
41         set_actions? @actions, @actions_names
42       end
43       describe 'baseに於いて' do
44       end
45       describe 'indexに於いて' do
46         before do
47           @action = @actions['index']
48         end
49         it 'listタイプのアクションである' do
50           expect(@action.type).to eq 'list'
51         end
52         it 'マニフェストから設定を取り出している' do
53           # 記法の公開リストを返すように定義している
54           set_list_action? @action, 'writing_format', 'public'
55         end
56       end
57       describe 'by_system_pictureに於いて' do
58         before do
59           @action = @actions['by_system_picture']
60         end
61         it 'listタイプのアクションである' do
62           expect(@action.type).to eq 'list'
63         end
64         it 'マニフェストから設定を取り出している' do
65           # 記法のシステム画像フィルタリストを返すように定義している
66           set_list_action? @action, 'writing_format', 'by_system_picture'
67         end
68       end
69       describe 'countに於いて' do
70         before do
71           @action = @actions['count']
72         end
73         it 'countタイプのアクションである' do
74           expect(@action.type).to eq 'count'
75         end
76         it 'マニフェストから設定を取り出している' do
77           #記法の公開リストのカウントを返すように定義している
78           set_list_action? @action, 'writing_format', 'public'
79         end
80       end
81       describe 'showに於いて' do
82         before do
83           @action = @actions['show']
84         end
85         it 'showタイプのアクションである' do
86           expect(@action.type).to eq 'show'
87         end
88       end
89       describe 'count_by_system_pictureに於いて' do
90         before do
91           @action = @actions['count_by_system_picture']
92         end
93         it 'countタイプのアクションである' do
94           expect(@action.type).to eq 'count'
95         end
96         it 'マニフェストから設定を取り出している' do
97           # 記法のシステム画像フィルタリストのカウントを返すように定義している
98           set_list_action? @action, 'writing_format', 'by_system_picture'
99         end
100       end
101       describe 'newに於いて' do
102         before do
103           @action = @actions['new']
104         end
105         it 'newタイプのアクションである' do
106           expect(@action.type).to eq 'new'
107         end
108         it 'type' do
109           expect(@action.item_name).to eq 'writing_format'
110         end
111       end
112       describe 'editに於いて' do
113         before do
114           @action = @actions['edit']
115         end
116         it 'editタイプのアクションである' do
117           expect(@action.type).to eq 'edit'
118         end
119         it 'type' do
120           expect(@action.item_name).to eq 'writing_format'
121         end
122       end
123       describe 'createに於いて' do
124         before do
125           @action = @actions['create']
126         end
127         it 'createタイプのアクションである' do
128           expect(@action.type).to eq 'create'
129         end
130         it 'type' do
131           expect(@action.item_name).to eq 'writing_format'
132         end
133       end
134       describe 'updateに於いて' do
135         before do
136           @action = @actions['update']
137         end
138         it 'updateタイプのアクションである' do
139           expect(@action.type).to eq 'update'
140         end
141         it 'type' do
142           expect(@action.item_name).to eq 'writing_format'
143         end
144       end
145       describe 'destroyに於いて' do
146         before do
147           @action = @actions['destroy']
148         end
149         it 'destroyタイプのアクションである' do
150           expect(@action.type).to eq 'destroy'
151         end
152         it 'type' do
153           expect(@action.item_name).to eq 'writing_format'
154         end
155       end
156     end
157     
158   end
159   
160   describe 'モデルに於いて' do
161     before do
162       @my_manifest = @model.my_manifest
163     end
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'
168     end
169     
170     describe 'associationsに於いて' do
171       describe 'belongs_toに於いて' do
172         before do
173           @belongs_to = @my_manifest.associations.belongs_to
174           @names = ['system_picture']
175         end
176         it 'これらのモデルに所属している' do
177           set_associations? @belongs_to, @names
178         end
179         describe 'system_pictureに於いて' do
180           before do
181             @mani = @belongs_to['system_picture']
182           end
183           it 'マニフェストから設定を取り出している' do
184             # モデル名と外部キーが定義あるいはデフォルト値補充されている
185             expect(@mani.model_name).to eq 'system_picture'
186             expect(@mani.id_column).to eq 'system_picture_id'
187           end
188           it 'サポート機能が動作している' do
189             # モデルを再現できている
190             expect(@mani.model).to eq SystemPicture
191           end
192         end
193       end
194       describe 'has_manyに於いて' do
195         before do
196           @has_many = @model.my_manifest.associations.has_many
197           @names = ['speeches']
198         end
199         it 'これらのモデルを所持している' do
200           set_associations? @has_many, @names
201         end
202         describe 'speechesに於いて' do
203           before do
204             @mani = @has_many['speeches']
205           end
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
211           end
212           it 'サポート機能が動作している' do
213             # モデルを再現できている, 中間モデルフラグ
214             expect(@mani.through?).to be false
215             expect(@mani.model).to eq Speech
216           end
217         end
218       end
219     end
220     
221     describe 'attributesに於いて' do
222       before do
223         @attributes = @model.my_manifest.attributes
224       end
225       it 'これらのカラムを定義している' do
226         set_attributes? @attributes, 
227           ['id', 'name', 'module_name', 'caption', 'system_picture_id', 'settings', 
228           'created_at', 'updated_at']
229       end
230       describe 'nameに於いて' do
231         before do
232           @attribute = @attributes['name']
233         end
234         it 'textタイプである' do
235           expect(@attribute.type).to eq 'text'
236         end
237       end
238       describe 'module_nameに於いて' do
239         before do
240           @attribute = @attributes['module_name']
241         end
242         it 'textタイプである' do
243           expect(@attribute.type).to eq 'text'
244         end
245       end
246       describe 'captionに於いて' do
247         before do
248           @attribute = @attributes['caption']
249         end
250         it 'textタイプである' do
251           expect(@attribute.type).to eq 'text'
252         end
253       end
254       describe 'system_picture_idに於いて' do
255         before do
256           @attribute = @attributes['system_picture_id']
257         end
258         it 'numberタイプである' do
259           expect(@attribute.type).to eq 'number'
260         end
261       end
262       describe 'settingsに於いて' do
263         before do
264           @attribute = @attributes['settings']
265         end
266         it 'textタイプである' do
267           expect(@attribute.type).to eq 'text'
268         end
269       end
270     end
271     
272   end
273   
274 end