OSDN Git Service

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