OSDN Git Service

add 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::Binder)).to eq true\r
13     end\r
14     it '親モデルは持たない' do\r
15       expect(@model.my_peta.parent_model_name).to be_blank\r
16     end\r
17     describe 'ブーストに於いて' do\r
18       it '特筆すべき注意事項はない' do\r
19         expect(@model.my_peta.boost.keys).to be_empty\r
20       end\r
21     end\r
22     \r
23   end\r
24   \r
25   describe 'コントローラに於いて' do\r
26     before do\r
27       @controller = @model.my_controller\r
28     end\r
29     it 'スクロールのためのコントローラである' do\r
30       expect(@model.item_name).to eq 'scroll'\r
31     end\r
32     describe 'actionに於いて' do\r
33       before do\r
34         @actions = @controller.actions\r
35         @actions_names = ['index', 'by_author', 'by_panel', 'play', 'show', \r
36           'count', 'count_by_author', 'count_by_panel', \r
37           'new', 'edit', 'create', 'update', 'destroy']\r
38       end\r
39       it 'これらのアクションが定義されている' do\r
40         set_actions? @actions, @actions_names\r
41       end\r
42       describe 'baseに於いて' do\r
43       end\r
44       describe 'indexに於いて' do\r
45         before do\r
46           @action = @actions['index']\r
47         end\r
48         it 'listタイプのアクションである' do\r
49           expect(@action.type).to eq 'list'\r
50         end\r
51         it 'マニフェストから設定を取り出している' do\r
52           # スクロールの公開リストを返すように定義している\r
53           set_list_action? @action, 'scroll', 'public'\r
54         end\r
55       end\r
56       describe 'by_authorに於いて' do\r
57         before do\r
58           @action = @actions['by_author']\r
59         end\r
60         it 'listタイプのアクションである' do\r
61           expect(@action.type).to eq 'list'\r
62         end\r
63         it 'マニフェストから設定を取り出している' do\r
64           # スクロールの作家フィルタリストを返すように定義している\r
65           set_list_action? @action, 'scroll', 'by_author'\r
66         end\r
67       end\r
68       describe 'by_panelに於いて' do\r
69         before do\r
70           @action = @actions['by_panel']\r
71         end\r
72         it 'listタイプのアクションである' do\r
73           expect(@action.type).to eq 'list'\r
74         end\r
75         it 'マニフェストから設定を取り出している' do\r
76           #スクロールのコマフィルタリストを返すように定義している\r
77           set_list_action? @action, 'scroll', 'by_panel'\r
78         end\r
79       end\r
80       describe 'countに於いて' do\r
81         before do\r
82           @action = @actions['count']\r
83         end\r
84         it 'countタイプのアクションである' do\r
85           expect(@action.type).to eq 'count'\r
86         end\r
87         it 'マニフェストから設定を取り出している' do\r
88           #スクロールの公開リストのカウントを返すように定義している\r
89           set_list_action? @action, 'scroll', 'public'\r
90         end\r
91       end\r
92       describe 'count_by_authorに於いて' do\r
93         before do\r
94           @action = @actions['count_by_author']\r
95         end\r
96         it 'countタイプのアクションである' do\r
97           expect(@action.type).to eq 'count'\r
98         end\r
99         it 'マニフェストから設定を取り出している' do\r
100           # スクロールの作家フィルタリストのカウントを返すように定義している\r
101           set_list_action? @action, 'scroll', 'by_author'\r
102         end\r
103       end\r
104       describe 'count_by_panelに於いて' do\r
105         before do\r
106           @action = @actions['count_by_panel']\r
107         end\r
108         it 'countタイプのアクションである' do\r
109           expect(@action.type).to eq 'count'\r
110         end\r
111         it 'マニフェストから設定を取り出している' do\r
112           # スクロールのコマフィルタリストのカウントを返すように定義している\r
113           set_list_action? @action, 'scroll', 'by_panel'\r
114         end\r
115       end\r
116       describe 'newに於いて' do\r
117         before do\r
118           @action = @actions['new']\r
119         end\r
120         it 'newタイプのアクションである' do\r
121           expect(@action.type).to eq 'new'\r
122         end\r
123         it 'type' do\r
124           expect(@action.item_name).to eq 'scroll'\r
125         end\r
126       end\r
127       describe 'editに於いて' do\r
128         before do\r
129           @action = @actions['edit']\r
130         end\r
131         it 'editタイプのアクションである' do\r
132           expect(@action.type).to eq 'edit'\r
133         end\r
134         it 'type' do\r
135           expect(@action.item_name).to eq 'scroll'\r
136         end\r
137       end\r
138       describe 'createに於いて' do\r
139         before do\r
140           @action = @actions['create']\r
141         end\r
142         it 'createタイプのアクションである' do\r
143           expect(@action.type).to eq 'create'\r
144         end\r
145         it 'type' do\r
146           expect(@action.item_name).to eq 'scroll'\r
147         end\r
148       end\r
149       describe 'updateに於いて' do\r
150         before do\r
151           @action = @actions['update']\r
152         end\r
153         it 'updateタイプのアクションである' do\r
154           expect(@action.type).to eq 'update'\r
155         end\r
156         it 'type' do\r
157           expect(@action.item_name).to eq 'scroll'\r
158         end\r
159       end\r
160       describe 'destroyに於いて' do\r
161         before do\r
162           @action = @actions['destroy']\r
163         end\r
164         it 'destroyタイプのアクションである' do\r
165           expect(@action.type).to eq 'destroy'\r
166         end\r
167         it 'type' do\r
168           expect(@action.item_name).to eq 'scroll'\r
169         end\r
170       end\r
171     end\r
172     \r
173   end\r
174   \r
175   describe 'モデルに於いて' do\r
176     before do\r
177       @my_manifest = @model.my_manifest\r
178     end\r
179     it 'サポート機能が動作している' do\r
180       expect(@my_manifest.model_name).to eq 'scroll'\r
181       expect(@my_manifest.classify).to eq @model\r
182       expect(@my_manifest.table_name).to eq 'scrolls'\r
183     end\r
184     \r
185     describe 'associationsに於いて' do\r
186       describe 'belongs_toに於いて' do\r
187         before do\r
188           @belongs_to = @my_manifest.associations.belongs_to\r
189           @names = ['author']\r
190         end\r
191         it 'これらのモデルに所属している' do\r
192           set_associations? @belongs_to, @names\r
193         end\r
194         describe 'authorに於いて' do\r
195           before do\r
196             @mani = @belongs_to['author']\r
197           end\r
198           it 'マニフェストから設定を取り出している' do\r
199             # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
200             expect(@mani.model_name).to eq 'author'\r
201             expect(@mani.id_column).to eq 'author_id'\r
202           end\r
203           it 'サポート機能が動作している' do\r
204             # モデルを再現できている\r
205             expect(@mani.model).to eq Author\r
206           end\r
207         end\r
208       end\r
209       describe 'has_manyに於いて' do\r
210         before do\r
211           @has_many = @model.my_manifest.associations.has_many\r
212           @names = ['scroll_panels', 'panels']\r
213         end\r
214         it 'これらのモデルを所持している' do\r
215           set_associations? @has_many, @names\r
216         end\r
217         describe 'scroll_panelsに於いて' do\r
218           before do\r
219             @mani = @has_many['scroll_panels']\r
220           end\r
221           it 'マニフェストから設定を取り出している' do\r
222             # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
223             expect(@mani.model_name).to eq 'scroll_panel'\r
224             expect(@mani.foreign_key).to eq 'scroll_id'\r
225             expect(@mani.through).to be nil\r
226           end\r
227           it 'サポート機能が動作している' do\r
228             # モデルを再現できている, 中間モデルフラグ\r
229             expect(@mani.through?).to be false\r
230             expect(@mani.model).to eq ScrollPanel\r
231           end\r
232         end\r
233         describe 'panelsに於いて' do\r
234           before do\r
235             @mani = @has_many['panels']\r
236           end\r
237           it 'マニフェストから設定を取り出している' do\r
238             # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
239             expect(@mani.model_name).to eq 'panel'\r
240             expect(@mani.foreign_key).to eq 'scroll_id'\r
241             expect(@mani.through).to eq 'scroll_panels'\r
242           end\r
243           it 'サポート機能が動作している' do\r
244             # モデルを再現できている, 中間モデルフラグ\r
245             expect(@mani.through?).to be true\r
246             expect(@mani.model).to eq Panel\r
247           end\r
248         end\r
249       end\r
250     end\r
251     \r
252     describe 'attributesに於いて' do\r
253       before do\r
254         @attributes = @model.my_manifest.attributes\r
255       end\r
256       it 'これらのカラムを定義している' do\r
257         set_attributes? @attributes, \r
258           ['id', 'title', 'description', 'visible', 'author_id', \r
259           'created_at', 'updated_at']\r
260       end\r
261       describe 'titleに於いて' do\r
262         before do\r
263           @attribute = @attributes['title']\r
264         end\r
265         it 'textタイプである' do\r
266           expect(@attribute.type).to eq 'text'\r
267         end\r
268       end\r
269       describe 'descriptionに於いて' do\r
270         before do\r
271           @attribute = @attributes['description']\r
272         end\r
273         it 'textタイプである' do\r
274           expect(@attribute.type).to eq 'text'\r
275         end\r
276       end\r
277       describe 'visibleに於いて' do\r
278         before do\r
279           @attribute = @attributes['visible']\r
280         end\r
281         it 'numberタイプである' do\r
282           expect(@attribute.type).to eq 'number'\r
283         end\r
284         it '選択肢を定数から取得できるように定義している' do\r
285           expect(@attribute.source.type).to eq 'magic_number'\r
286           expect(@attribute.source.select_item_name).to eq 'scroll_visible_items'\r
287         end\r
288       end\r
289       describe 'author_idに於いて' do\r
290         before do\r
291           @attribute = @attributes['author_id']\r
292         end\r
293         it 'numberタイプである' do\r
294           expect(@attribute.type).to eq 'number'\r
295         end\r
296       end\r
297     end\r
298     \r
299   end\r
300   \r
301 end\r