OSDN Git Service

add test
[pettanr/pettanr.git] / spec / manifests / comic_story_spec.rb
1 # -*- encoding: utf-8 -*-
2 require 'spec_helper'
3 # コミスト
4
5 describe ComicStory do
6   include ManifestsMacros
7   before do
8     @model = ComicStory
9   end
10   
11   describe 'ペタナイズに於いて' do
12     it 'コミックにストーリーを差し込むためのリーフである' do
13       expect(@model.ancestors.include?(Peta::Leaf)).to eq true
14     end
15     it '親モデルはコミックである' do
16       expect(@model.my_peta.parent_model_name).to eq 'comic'
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 'comic_story'
32     end
33     describe 'actionに於いて' do
34       before do
35         @actions = @controller.actions
36         @actions_names = ['index', 'by_comic', 'by_story', 'show', 
37           'count', 'count_by_comic', 'count_by_story', 
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, 'comic_story', 'public'
55         end
56       end
57       describe 'by_comicに於いて' do
58         before do
59           @action = @actions['by_comic']
60         end
61         it 'listタイプのアクションである' do
62           expect(@action.type).to eq 'list'
63         end
64         it 'マニフェストから設定を取り出している' do
65           # コミストの作家フィルタリストを返すように定義している
66           set_list_action? @action, 'comic_story', 'by_comic'
67         end
68       end
69       describe 'by_storyに於いて' do
70         before do
71           @action = @actions['by_story']
72         end
73         it 'listタイプのアクションである' do
74           expect(@action.type).to eq 'list'
75         end
76         it 'マニフェストから設定を取り出している' do
77           #コミストのコマフィルタリストを返すように定義している
78           set_list_action? @action, 'comic_story', 'by_story'
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に於いて' do
90         before do
91           @action = @actions['count']
92         end
93         it 'countタイプのアクションである' do
94           expect(@action.type).to eq 'count'
95         end
96         it 'マニフェストから設定を取り出している' do
97           #コミストの公開リストのカウントを返すように定義している
98           set_list_action? @action, 'comic_story', 'public'
99         end
100       end
101       describe 'count_by_comicに於いて' do
102         before do
103           @action = @actions['count_by_comic']
104         end
105         it 'countタイプのアクションである' do
106           expect(@action.type).to eq 'count'
107         end
108         it 'マニフェストから設定を取り出している' do
109           # コミストの作家フィルタリストのカウントを返すように定義している
110           set_list_action? @action, 'comic_story', 'by_comic'
111         end
112       end
113       describe 'count_by_storyに於いて' do
114         before do
115           @action = @actions['count_by_story']
116         end
117         it 'countタイプのアクションである' do
118           expect(@action.type).to eq 'count'
119         end
120         it 'マニフェストから設定を取り出している' do
121           # コミストのコマフィルタリストのカウントを返すように定義している
122           set_list_action? @action, 'comic_story', 'by_story'
123         end
124       end
125       describe 'newに於いて' do
126         before do
127           @action = @actions['new']
128         end
129         it 'newタイプのアクションである' do
130           expect(@action.type).to eq 'new'
131         end
132         it 'type' do
133           expect(@action.item_name).to eq 'comic_story'
134         end
135       end
136       describe 'editに於いて' do
137         before do
138           @action = @actions['edit']
139         end
140         it 'editタイプのアクションである' do
141           expect(@action.type).to eq 'edit'
142         end
143         it 'type' do
144           expect(@action.item_name).to eq 'comic_story'
145         end
146       end
147       describe 'createに於いて' do
148         before do
149           @action = @actions['create']
150         end
151         it 'createタイプのアクションである' do
152           expect(@action.type).to eq 'create'
153         end
154         it 'type' do
155           expect(@action.item_name).to eq 'comic_story'
156         end
157       end
158       describe 'updateに於いて' do
159         before do
160           @action = @actions['update']
161         end
162         it 'updateタイプのアクションである' do
163           expect(@action.type).to eq 'update'
164         end
165         it 'type' do
166           expect(@action.item_name).to eq 'comic_story'
167         end
168       end
169       describe 'destroyに於いて' do
170         before do
171           @action = @actions['destroy']
172         end
173         it 'destroyタイプのアクションである' do
174           expect(@action.type).to eq 'destroy'
175         end
176         it 'type' do
177           expect(@action.item_name).to eq 'comic_story'
178         end
179       end
180     end
181     
182   end
183   
184   describe 'モデルに於いて' do
185     before do
186       @my_manifest = @model.my_manifest
187     end
188     it 'サポート機能が動作している' do
189       expect(@my_manifest.model_name).to eq 'comic_story'
190       expect(@my_manifest.classify).to eq @model
191       expect(@my_manifest.table_name).to eq 'comic_stories'
192     end
193     
194     describe 'associationsに於いて' do
195       describe 'belongs_toに於いて' do
196         before do
197           @belongs_to = @my_manifest.associations.belongs_to
198           @names = ['comic', 'story']
199         end
200         it 'これらのモデルに所属している' do
201           set_associations? @belongs_to, @names
202         end
203         describe 'comicに於いて' do
204           before do
205             @mani = @belongs_to['comic']
206           end
207           it 'マニフェストから設定を取り出している' do
208             # モデル名と外部キーが定義あるいはデフォルト値補充されている
209             expect(@mani.model_name).to eq 'comic'
210             expect(@mani.id_column).to eq 'comic_id'
211           end
212           it 'サポート機能が動作している' do
213             # モデルを再現できている
214             expect(@mani.model).to eq Comic
215           end
216         end
217         describe 'storyに於いて' do
218           before do
219             @mani = @belongs_to['story']
220           end
221           it 'マニフェストから設定を取り出している' do
222             # モデル名と外部キーが定義あるいはデフォルト値補充されている
223             expect(@mani.model_name).to eq 'story'
224             expect(@mani.id_column).to eq 'story_id'
225           end
226           it 'サポート機能が動作している' do
227             # モデルを再現できている
228             expect(@mani.model).to eq Story
229           end
230         end
231       end
232       describe 'has_manyに於いて' do
233         before do
234           @has_many = @model.my_manifest.associations.has_many
235           @names = []
236         end
237         it 'これらのモデルを所持している' do
238           set_associations? @has_many, @names
239         end
240       end
241     end
242     
243     describe 'attributesに於いて' do
244       before do
245         @attributes = @model.my_manifest.attributes
246       end
247       it 'これらのカラムを定義している' do
248         set_attributes? @attributes, 
249           ['id', 'comic_id', 'story_id', 't', 
250           'created_at', 'updated_at']
251       end
252       describe 'comic_idに於いて' do
253         before do
254           @attribute = @attributes['comic_id']
255         end
256         it 'numberタイプである' do
257           expect(@attribute.type).to eq 'number'
258         end
259       end
260       describe 'story_idに於いて' do
261         before do
262           @attribute = @attributes['story_id']
263         end
264         it 'numberタイプである' do
265           expect(@attribute.type).to eq 'number'
266         end
267       end
268       describe 'tに於いて' do
269         before do
270           @attribute = @attributes['t']
271         end
272         it 'numberタイプである' do
273           expect(@attribute.type).to eq 'number'
274         end
275       end
276     end
277     
278   end
279   
280 end