OSDN Git Service

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