OSDN Git Service

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