OSDN Git Service

fix test
[pettanr/pettanr.git] / spec / manifests / balloon_spec.rb
1 # -*- encoding: utf-8 -*-\r
2 require 'spec_helper'\r
3 #フキダシ枠\r
4 describe Balloon do\r
5   include ManifestsMacros\r
6   before do\r
7     @model = Balloon\r
8   end\r
9   \r
10   describe 'ペタナイズに於いて' do\r
11     it 'フキダシの要素として利用されるエレメントである' do\r
12       expect(@model.ancestors.include?(Peta::Element)).to eq true\r
13     end\r
14     it '親モデルはフキダシである' do\r
15       expect(@model.my_peta.parent_model_name).to eq 'speech_balloon'\r
16     end\r
17     describe 'ブーストに於いて' do\r
18       before do\r
19         @boosts = @model.my_peta.boost\r
20         @boosts_names = ['speech_balloon_template']\r
21       end\r
22       it 'これらのブーストが定義されている' do\r
23         set_boosts? @boosts, @boosts_names\r
24       end\r
25       describe 'フキダシテンプレートに於いて' do\r
26         before do\r
27           @mani = @boosts['speech_balloon_template']\r
28         end\r
29         it 'システム起動前に初期化可能なサポート機能が動作している' do\r
30           expect(@mani.level).to eq 'post'\r
31           expect(@mani.template_name).to eq 'speech_balloon_template'\r
32           expect(@mani.column_name_for_template_module).to eq 'speech_balloon_template_module_name'\r
33           expect(@mani.settings_column_name).to eq 'speech_balloon_template_settings'\r
34           expect(@mani.foreign_key).to eq 'speech_balloon_template_id'\r
35         end\r
36         it 'システム起動後にしか初期化できないサポート機能が動作している' do\r
37           expect(@mani.item_name_for_extend_model).to eq 'balloon'\r
38           expect(@mani.setter_method_name).to eq 'balloon_extend='\r
39           expect(@mani.getter_method_name).to eq 'balloon_extend'\r
40           expect(@mani.extend_model_class_name).to eq 'Balloon'\r
41           expect(@mani.extend_module_name).to eq 'BalloonModule'\r
42         end\r
43       end\r
44     end\r
45     \r
46   end\r
47   \r
48   describe 'コントローラに於いて' do\r
49     before do\r
50       @controller = @model.my_controller\r
51     end\r
52     it 'フキダシ枠のためのコントローラである' do\r
53       expect(@model.item_name).to eq 'balloon'\r
54     end\r
55     describe 'actionに於いて' do\r
56       before do\r
57         @actions = @controller.actions\r
58         @actions_names = ['index', 'by_author', 'show', \r
59           'count', 'count_by_author', \r
60           'new', 'edit']\r
61       end\r
62       it 'これらのアクションが定義されている' do\r
63         set_actions? @actions, @actions_names\r
64       end\r
65       describe 'baseに於いて' do\r
66       end\r
67       describe 'indexに於いて' do\r
68         before do\r
69           @action = @actions['index']\r
70         end\r
71         it 'listタイプのアクションである' do\r
72           expect(@action.type).to eq 'list'\r
73         end\r
74         it 'マニフェストから設定を取り出している' do\r
75           # フキダシ枠の公開リストを返すように定義している\r
76           set_list_action? @action, 'balloon', 'public'\r
77         end\r
78       end\r
79       describe 'by_authorに於いて' do\r
80         before do\r
81           @action = @actions['by_author']\r
82         end\r
83         it 'listタイプのアクションである' do\r
84           expect(@action.type).to eq 'list'\r
85         end\r
86         it 'マニフェストから設定を取り出している' do\r
87           # フキダシ枠の作家フィルタリストを返すように定義している\r
88           set_list_action? @action, 'balloon', 'by_author'\r
89         end\r
90       end\r
91       describe 'countに於いて' do\r
92         before do\r
93           @action = @actions['count']\r
94         end\r
95         it 'countタイプのアクションである' do\r
96           expect(@action.type).to eq 'count'\r
97         end\r
98         it 'マニフェストから設定を取り出している' do\r
99           #フキダシ枠の公開リストのカウントを返すように定義している\r
100           set_list_action? @action, 'balloon', 'public'\r
101         end\r
102       end\r
103       describe 'count_by_authorに於いて' do\r
104         before do\r
105           @action = @actions['count_by_author']\r
106         end\r
107         it 'countタイプのアクションである' do\r
108           expect(@action.type).to eq 'count'\r
109         end\r
110         it 'マニフェストから設定を取り出している' do\r
111           # フキダシ枠の作家フィルタリストのカウントを返すように定義している\r
112           set_list_action? @action, 'balloon', 'by_author'\r
113         end\r
114       end\r
115       describe 'newに於いて' do\r
116         before do\r
117           @action = @actions['new']\r
118         end\r
119         it 'newタイプのアクションである' do\r
120           expect(@action.type).to eq 'new'\r
121         end\r
122         it 'type' do\r
123           expect(@action.item_name).to eq 'balloon'\r
124         end\r
125       end\r
126       describe 'editに於いて' do\r
127         before do\r
128           @action = @actions['edit']\r
129         end\r
130         it 'editタイプのアクションである' do\r
131           expect(@action.type).to eq 'edit'\r
132         end\r
133         it 'type' do\r
134           expect(@action.item_name).to eq 'balloon'\r
135         end\r
136       end\r
137     end\r
138     \r
139   end\r
140   \r
141   describe 'モデルに於いて' do\r
142     before do\r
143       @my_manifest = @model.my_manifest\r
144     end\r
145     it 'サポート機能が動作している' do\r
146       expect(@my_manifest.model_name).to eq 'balloon'\r
147       expect(@my_manifest.classify).to eq @model\r
148       expect(@my_manifest.table_name).to eq 'balloons'\r
149     end\r
150     \r
151     describe 'associationsに於いて' do\r
152       describe 'belongs_toに於いて' do\r
153         before do\r
154           @belongs_to = @my_manifest.associations.belongs_to\r
155           @names = ['speech_balloon', 'system_picture', 'speech_balloon_template']\r
156         end\r
157         it 'これらのモデルに所属している' do\r
158           set_associations? @belongs_to, @names\r
159         end\r
160         describe 'speech_balloonに於いて' do\r
161           before do\r
162             @mani = @belongs_to['speech_balloon']\r
163           end\r
164           it 'マニフェストから設定を取り出している' do\r
165             # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
166             expect(@mani.model_name).to eq 'speech_balloon'\r
167             expect(@mani.id_column).to eq 'speech_balloon_id'\r
168           end\r
169           it 'サポート機能が動作している' do\r
170             # モデルを再現できている\r
171             expect(@mani.model).to eq SpeechBalloon\r
172           end\r
173         end\r
174         describe 'system_pictureに於いて' do\r
175           before do\r
176             @mani = @belongs_to['system_picture']\r
177           end\r
178           it 'マニフェストから設定を取り出している' do\r
179             # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
180             expect(@mani.model_name).to eq 'system_picture'\r
181             expect(@mani.id_column).to eq 'system_picture_id'\r
182           end\r
183           it 'サポート機能が動作している' do\r
184             # モデルを再現できている\r
185             expect(@mani.model).to eq SystemPicture\r
186           end\r
187         end\r
188         describe 'speech_balloon_templateに於いて' do\r
189           before do\r
190             @mani = @belongs_to['speech_balloon_template']\r
191           end\r
192           it 'マニフェストから設定を取り出している' do\r
193             # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
194             expect(@mani.model_name).to eq 'speech_balloon_template'\r
195             expect(@mani.id_column).to eq 'speech_balloon_template_id'\r
196           end\r
197           it 'サポート機能が動作している' do\r
198             # モデルを再現できている\r
199             expect(@mani.model).to eq SpeechBalloonTemplate\r
200           end\r
201         end\r
202       end\r
203       describe 'has_manyに於いて' do\r
204         before do\r
205           @has_many = @model.my_manifest.associations.has_many\r
206           @names = []\r
207         end\r
208         it 'これらのモデルを所持している' do\r
209           set_associations? @has_many, @names\r
210         end\r
211       end\r
212     end\r
213     \r
214     describe 'attributesに於いて' do\r
215       before do\r
216         @attributes = @model.my_manifest.attributes\r
217       end\r
218       it 'これらのカラムを定義している' do\r
219         set_attributes? @attributes, \r
220           ['id', 'speech_balloon_id', 'speech_balloon_template_id', 'speech_balloon_template_module_name', \r
221           'system_picture_id', 'x', 'y', 'width', 'height', 'r', \r
222           'speech_balloon_template_settings', \r
223           'created_at', 'updated_at']\r
224       end\r
225       describe 'speech_balloon_idに於いて' do\r
226         before do\r
227           @attribute = @attributes['speech_balloon_id']\r
228         end\r
229         it 'numberタイプである' do\r
230           expect(@attribute.type).to eq 'number'\r
231         end\r
232       end\r
233       describe 'speech_balloon_template_idに於いて' do\r
234         before do\r
235           @attribute = @attributes['speech_balloon_template_id']\r
236         end\r
237         it 'numberタイプである' do\r
238           expect(@attribute.type).to eq 'number'\r
239         end\r
240       end\r
241       describe 'speech_balloon_template_module_nameに於いて' do\r
242         before do\r
243           @attribute = @attributes['speech_balloon_template_module_name']\r
244         end\r
245         it 'textタイプである' do\r
246           expect(@attribute.type).to eq 'text'\r
247         end\r
248       end\r
249       describe 'system_picture_idに於いて' do\r
250         before do\r
251           @attribute = @attributes['system_picture_id']\r
252         end\r
253         it 'numberタイプである' do\r
254           expect(@attribute.type).to eq 'number'\r
255         end\r
256       end\r
257       describe 'xに於いて' do\r
258         before do\r
259           @attribute = @attributes['x']\r
260         end\r
261         it 'numberタイプである' do\r
262           expect(@attribute.type).to eq 'number'\r
263         end\r
264       end\r
265       describe 'yに於いて' do\r
266         before do\r
267           @attribute = @attributes['y']\r
268         end\r
269         it 'numberタイプである' do\r
270           expect(@attribute.type).to eq 'number'\r
271         end\r
272       end\r
273       describe 'widthに於いて' do\r
274         before do\r
275           @attribute = @attributes['width']\r
276         end\r
277         it 'numberタイプである' do\r
278           expect(@attribute.type).to eq 'number'\r
279         end\r
280       end\r
281       describe 'heightに於いて' do\r
282         before do\r
283           @attribute = @attributes['height']\r
284         end\r
285         it 'numberタイプである' do\r
286           expect(@attribute.type).to eq 'number'\r
287         end\r
288       end\r
289       describe 'rに於いて' do\r
290         before do\r
291           @attribute = @attributes['r']\r
292         end\r
293         it 'numberタイプである' do\r
294           expect(@attribute.type).to eq 'number'\r
295         end\r
296       end\r
297       describe 'speech_balloon_template_settingsに於いて' do\r
298         before do\r
299           @attribute = @attributes['speech_balloon_template_settings']\r
300         end\r
301         it 'textタイプである' do\r
302           expect(@attribute.type).to eq 'text'\r
303         end\r
304       end\r
305     end\r
306     \r
307   end\r
308   \r
309 end\r