OSDN Git Service

picture's test are all green
[pettanr/pettanr.git] / spec / models / resource_picture_spec.rb
1 # -*- encoding: utf-8 -*-\r
2 require 'spec_helper'
3
4 describe ResourcePicture do
5   before do
6     Factory :admin
7     @user = Factory( :user_yas)
8     @author = @user.author
9     @artist = Factory :artist_yas, :author_id => @author.id\r
10     @other_user = Factory( :user_yas)
11     @other_author = @other_user.author
12     @other_artist = Factory :artist_yas, :author_id => @other_author.id
13     @license = Factory :license
14     @original_picture = Factory :original_picture, :artist_id => @artist.id, :license_id => @license.id\r
15     
16     class Mgk ; class Image ; end ; end
17     Mgk::Image.stub(:from_blob).with(any_args).and_return([Mgk.new])
18     Mgk.any_instance.stub(:format).with(any_args).and_return('png')
19     Mgk.any_instance.stub(:format=).with(any_args)
20     Mgk.any_instance.stub(:rows).with(any_args).and_return(200)
21     Mgk.any_instance.stub(:columns).with(any_args).and_return(100)
22     Mgk.any_instance.stub(:filesize).with(any_args).and_return(20000)
23     Mgk.any_instance.stub(:to_blob).with(any_args).and_return('data')
24     #原画ファイル削除だけは必ず成功するものとしておく
25     PictureIO::LocalPicture.any_instance.stub(:delete).with(any_args).and_return(true)
26   end\r
27   
28   describe '検証に於いて' do
29     before do\r
30     end
31     
32     it 'オーソドックスなデータなら通る' do
33       @rp = Factory.build :resource_picture, :artist_id => @artist.id, :original_picture_id => @original_picture.id, :license_id => @license.id
34       @rp.should be_valid
35     end
36     
37     context 'extを検証するとき' do
38       before do
39         @rp = Factory.build :resource_picture, \r
40           :artist_id => @artist.id, :original_picture_id => @original_picture.id, :license_id => @license.id
41       end
42       it 'テストデータの確認' do
43         @rp.ext = 'jpeg'
44         @rp.should be_valid
45       end
46       it 'nullなら失敗する' do
47         @rp.ext = ''
48         @rp.should_not be_valid
49       end
50       it '5文字以上なら失敗する' do
51         @rp.ext = 'a'*5
52         @rp.should_not be_valid
53       end
54       it 'png,gif,jpeg以外なら失敗する' do
55         @rp.ext = 'bmp'
56         @rp.should_not be_valid
57       end
58     end
59     context 'widthを検証するとき' do
60       before do
61         @rp = Factory.build :resource_picture, \r
62           :artist_id => @artist.id, :original_picture_id => @original_picture.id, :license_id => @license.id
63       end
64       it 'テストデータの確認' do
65         @rp.width = 1
66         @rp.should be_valid
67       end
68       it 'nullなら失敗する' do
69         @rp.width = nil
70         @rp.should_not be_valid
71       end
72       it '数値でなければ失敗する' do
73         @rp.width = 'a'
74         @rp.should_not be_valid
75       end
76       it '0なら失敗する' do
77         @rp.width = '0'
78         @rp.should_not be_valid
79       end
80       it '負でも失敗する' do
81         @rp.width = -1
82         @rp.should_not be_valid
83       end
84     end
85     context 'heightを検証するとき' do
86       before do
87         @rp = Factory.build :resource_picture, \r
88           :artist_id => @artist.id, :original_picture_id => @original_picture.id, :license_id => @license.id
89       end
90       it 'テストデータの確認' do
91         @rp.height = '1'
92         @rp.should be_valid
93       end
94       it 'nullなら失敗する' do
95         @rp.height = nil
96         @rp.should_not be_valid
97       end
98       it '数値でなければ失敗する' do
99         @rp.height = 'a'
100         @rp.should_not be_valid
101       end
102       it '0なら失敗する' do
103         @rp.height = '0'
104         @rp.should_not be_valid
105       end
106       it '負でも失敗する' do
107         @rp.height = -1
108         @rp.should_not be_valid
109       end
110     end
111     context 'filesizeを検証するとき' do
112       before do
113         @rp = Factory.build :resource_picture, \r
114           :artist_id => @artist.id, :original_picture_id => @original_picture.id, :license_id => @license.id
115       end
116       it 'テストデータの確認' do
117         @rp.filesize = '1'
118         @rp.should be_valid
119       end
120       it 'nullなら失敗する' do
121         @rp.filesize = nil
122         @rp.should_not be_valid
123       end
124       it '数値でなければ失敗する' do
125         @rp.filesize = 'a'
126         @rp.should_not be_valid
127       end
128       it '負なら失敗する' do
129         @rp.filesize = '-1'
130         @rp.should_not be_valid
131       end
132       it '2MB以上なら失敗する' do
133         @rp.filesize = 2000000+1
134         @rp.should_not be_valid
135       end
136     end
137     context 'artist_idを検証するとき' do
138       before do
139         @rp = Factory.build :resource_picture, \r
140           :original_picture_id => @original_picture.id, :license_id => @license.id
141       end
142       it 'テストデータの確認' do
143         @rp.artist_id = @artist.id
144         @rp.should be_valid
145       end
146       it 'nullなら失敗する' do
147         @rp.artist_id = nil
148         @rp.should_not be_valid
149       end
150       it '数値でなければ失敗する' do
151         @rp.artist_id = 'a'
152         @rp.should_not be_valid
153       end
154       it '存在する絵師でなければ失敗する' do
155         @rp.artist_id = 0
156         @rp.should_not be_valid
157       end
158     end
159     context 'license_idを検証するとき' do
160       before do
161         @rp = Factory.build :resource_picture, \r
162           :artist_id => @artist.id, :original_picture_id => @original_picture.id
163       end
164       it 'テストデータの確認' do
165         @rp.license_id = @license.id
166         @rp.should be_valid
167       end
168       it 'nullなら失敗する' do
169         @rp.license_id = nil
170         @rp.should_not be_valid
171       end
172       it '数値でなければ失敗する' do
173         @rp.license_id = 'a'
174         @rp.should_not be_valid
175       end
176       it '存在する絵師でなければ失敗する' do
177         @rp.license_id = 0
178         @rp.should_not be_valid
179       end
180     end
181     context 'original_picture_idを検証するとき' do
182       before do
183         @rp = Factory.build :resource_picture, \r
184           :artist_id => @artist.id, :license_id => @license.id
185       end
186       it 'テストデータの確認' do
187         @rp.original_picture_id = @original_picture.id
188         @rp.should be_valid
189       end
190       it 'nullなら失敗する' do
191         @rp.original_picture_id = nil
192         @rp.should_not be_valid
193       end
194       it '数値でなければ失敗する' do
195         @rp.original_picture_id = 'a'
196         @rp.should_not be_valid
197       end
198       it '存在する原画でなければ失敗する' do
199         @rp.original_picture_id = 0
200         @rp.should_not be_valid
201       end
202     end
203   end
204   
205   describe 'データ補充に於いて' do
206     before do
207     end
208     
209   end
210   \r
211   describe 'サイズの調整に於いて' do
212     before do
213     end
214     
215     it 'サイズに収まるときはそのまま使う' do
216       ResourcePicture.fix_size_both(64, 64, 64, 64).should eq [64, 64]
217     end
218     it '小さくても拡大しない' do
219       ResourcePicture.fix_size_both(64, 64, 32, 32).should eq [32, 32]
220     end
221     it '縦長のときは縦に合わせて縮小' do
222       ResourcePicture.fix_size_both(64, 64, 64, 128).should eq [32, 64]
223     end
224     it '横長のときは横に合わせて縮小' do
225       ResourcePicture.fix_size_both(64, 64, 128, 64).should eq [64, 32]
226     end
227   end
228   \r
229   describe 'フォーマット変換対象判定に於いて' do
230     before do
231       @rp = Factory.build :resource_picture, \r
232         :artist_id => @artist.id, :license_id => @license.id
233     end
234     context '変換するケース' do\r
235       it '画像フォーマットがpngかつライセンスの変換禁止フラグが無効のときTrue' do\r
236         License.any_instance.stub(:no_convert).with(any_args).and_return(0)
237         @rp.ext = 'png'\r
238         @rp.to_gif?.should be_true
239       end
240     end
241     context '変換しないケース' do
242       it '画像フォーマットがでない' do\r
243         License.any_instance.stub(:no_convert).with(any_args).and_return(0)
244         @rp.ext = 'gif'\r
245         @rp.to_gif?.should be_false
246       end
247       it 'ライセンスの変換禁止フラグが無効' do\r
248         License.any_instance.stub(:no_convert).with(any_args).and_return(1)
249         @rp.ext = 'png'\r
250         @rp.to_gif?.should be_false
251       end
252     end
253   end
254   
255   describe 'Gifフォーマット変換に於いて' do
256     before do
257       Magick::Image.stub(:from_blob).with(any_args).and_return([Mgk.new])
258     end
259     context 'つつがなく終わるとき' do
260       it 'Mgkオブジェクトが返る' do
261         mgk = ResourcePicture.png_to_gif('mgkbin')\r
262         mgk.is_a?(Mgk).should be_true
263       end
264       it 'Mgkオブジェクトはgif変換されている' do\r
265         #スタブばかりで変換できないので代入されているかでチェックする
266         Mgk.any_instance.should_receive(:format=).with('gif').exactly(1)
267         ResourcePicture.png_to_gif('mgkbin')\r
268       end
269     end
270     context 'RMagick変換が失敗したとき' do
271       before do
272         Magick::Image.should_receive(:from_blob).with(any_args).and_raise('StandardError')
273       end
274       it 'falseを返す' do
275         res = ResourcePicture.png_to_gif('mgkbin')\r
276         res.should be_false\r
277       end
278     end
279   end
280   
281   describe '対象素材の取得に於いて' do
282     before do\r
283       @op = Factory.build :original_picture, :ext => 'jpeg', :width => 264, :height => 265, :filesize => 266, \r
284         :artist_id => @artist.id, :license_id => @license.id
285       @rp = Factory.build :resource_picture, \r
286         :artist_id => @artist.id, :license_id => @license.id
287     end
288     context '原画オブジェクトが素材を持っている(更新ケース)' do
289       before do\r
290         OriginalPicture.any_instance.stub(:resource_picture).with(any_args).and_return(@rp)\r
291       end
292       it 'それを対象素材として返す' do
293         res = ResourcePicture.update_picture(@op)\r
294         res.should eq @rp\r
295       end
296     end
297     context '持っていない(新規作成ケース)' do
298       before do\r
299         OriginalPicture.any_instance.stub(:resource_picture).with(any_args).and_return(nil)\r
300       end
301       it '新規素材モデルを用意し、それを対象素材として返す' do
302         res = ResourcePicture.update_picture(@op)\r
303         res.should be_a_new ResourcePicture\r
304       end\r
305       it '原画オブジェクトから属性を取り出して対象素材にセットしている' do
306         res = ResourcePicture.update_picture(@op)\r
307         res.ext.should eq 'jpeg'\r
308         res.width.should eq 264\r
309         res.height.should eq 265\r
310         res.filesize.should eq 266\r
311         res.artist_id.should eq @artist.id\r
312         res.license_id.should eq @license.id\r
313       end\r
314       
315     end
316   end
317   
318   describe '作成・更新に於いて' do
319     before do
320       @op = Factory :original_picture, :artist_id => @artist.id, :license_id => @license.id
321       @rp = Factory.build :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id
322     end
323     context '事前チェック' do
324       before do
325         #すべての処理が正常パターンで通過すれば、一番深い分岐まで通る。
326         #それで外部のメソッド呼び出しだけに着目してテストする。
327         ResourcePicture.any_instance.stub(:save).with(any_args).and_return(true)\r
328         ResourcePicture.any_instance.stub(:store_picture).with(any_args).and_return(true)\r
329         ResourcePicture.stub(:to_gif?).with(any_args).and_return(true)\r
330         class GifMgk < Mgk ; end  #store_pictureは二回呼び出される。区別をつけるために\r
331         @gifmgk = GifMgk.new      #パラメータを二種類用意する。\r
332         ResourcePicture.stub(:png_to_gif).with(any_args).and_return(@gifmgk)
333       end
334       it '自身を保存している' do
335         ResourcePicture.any_instance.should_receive(:save).with(any_args).exactly(1)
336         res = @rp.store(Mgk.new)\r
337       end\r
338       it '画像ファイルの作成・更新機能で画像を保存している' do\r
339         mgk = Mgk.new   #一回目の本画像保存は与えたオブジェクトを使って保存する。
340         ResourcePicture.any_instance.should_receive(:store_picture).with(mgk).exactly(1)
341         res = @rp.store(mgk)\r
342       end\r
343       it '自身にフォーマット変換対象かを問い合わせている' do
344         ResourcePicture.any_instance.should_receive(:to_gif?).with(any_args).exactly(1)
345         res = @rp.store(Mgk.new)\r
346       end\r
347       it '自身にGifフォーマット変換を依頼している' do
348         ResourcePicture.should_receive(:png_to_gif).with(any_args).exactly(1)
349         res = @rp.store(Mgk.new)\r
350       end\r
351       it '画像ファイルの作成・更新機能でgif画像を保存している' do\r
352         #二回目の保存はgif変換の結果を渡す。
353         ResourcePicture.any_instance.should_receive(:store_picture).with(@gifmgk).exactly(1)
354         res = @rp.store(Mgk.new)\r
355       end\r
356     end
357     context 'つつがなく終わるとき' do
358       before do
359         #すべての処理を正常パターンで通過させ、保存機能をチェックする。
360 #        ResourcePicture.any_instance.stub(:save).with(any_args).and_return(true)\r
361         ResourcePicture.any_instance.stub(:store_picture).with(any_args).and_return(true)\r
362         ResourcePicture.any_instance.stub(:to_gif?).with(any_args).and_return(true)\r
363         class GifMgk < Mgk ; end  #store_pictureは二回呼び出される。区別をつけるために\r
364         @gifmgk = GifMgk.new      #パラメータを二種類用意する。\r
365         ResourcePicture.stub(:png_to_gif).with(any_args).and_return(@gifmgk)
366       end
367       it 'Trueを返す' do
368         res = @rp.store(Mgk.new)\r
369         res.should be_true\r
370       end\r
371       it '自身が保存されている' do\r
372         lambda {
373           res = @rp.store(Mgk.new)\r
374         }.should change ResourcePicture, :count\r
375       end\r
376     end
377     context 'gif変換なしで、つつがなく終わるとき' do
378       before do
379         #すべての処理を正常パターンで通過させ、保存機能をチェックする。
380         ResourcePicture.any_instance.stub(:save).with(any_args).and_return(true)\r
381         ResourcePicture.any_instance.stub(:store_picture).with(any_args).and_return(true)\r
382         ResourcePicture.any_instance.stub(:to_gif?).with(any_args).and_return(false)\r
383       end
384       it 'Trueを返す' do
385         res = @rp.store(Mgk.new)\r
386         res.should be_true\r
387       end\r
388       it 'gif保存は呼ばれていない' do\r
389         ResourcePicture.any_instance.should_receive(:store_picture).with(any_args).exactly(1)
390         res = @rp.store(Mgk.new)\r
391       end\r
392     end
393     #以下から例外ケース。処理先頭から失敗させていく
394     context '自身の保存に失敗したとき' do
395       before do
396         ResourcePicture.any_instance.stub(:save).with(any_args).and_return(false)\r
397       end
398       it 'Falseを返す' do
399         res = @rp.store(Mgk.new)\r
400         res.should be_false\r
401       end\r
402       it '更新されていない' do
403         @rp.store(Mgk.new)
404         @rp.should be_a_new ResourcePicture\r
405       end
406     end
407     context '画像の保存に失敗したとき' do
408       before do
409         ResourcePicture.any_instance.stub(:save).with(any_args).and_return(true)\r
410         ResourcePicture.any_instance.stub(:store_picture).with(any_args).and_return(false)\r
411       end
412       it 'Falseを返す' do
413         res = @rp.store(Mgk.new)\r
414         res.should be_false\r
415       end\r
416       it 'gif変換判定は呼ばれていない' do\r
417         ResourcePicture.any_instance.should_not_receive(:to_gif?).with(any_args)
418         res = @rp.store(Mgk.new)\r
419       end\r
420     end
421     context 'gif変換に失敗したとき' do
422       before do
423         ResourcePicture.any_instance.stub(:save).with(any_args).and_return(true)\r
424         ResourcePicture.any_instance.stub(:store_picture).with(any_args).and_return(true)\r
425         ResourcePicture.any_instance.stub(:to_gif?).with(any_args).and_return(true)\r
426         ResourcePicture.stub(:png_to_gif).with(any_args).and_return(false)
427       end
428       it 'Falseを返す' do
429         res = @rp.store(Mgk.new)\r
430         res.should be_false\r
431       end\r
432       it 'gif画像の保存は呼ばれていない' do\r
433         #本画像の保存があるので、一度は呼ばれる\r
434         ResourcePicture.any_instance.should_receive(:store_picture).with(any_args).exactly(1)
435         res = @rp.store(Mgk.new)\r
436       end\r
437     end
438     context 'gif画像の保存に失敗したとき' do
439       before do\r
440         @mgk = Mgk.new
441         ResourcePicture.any_instance.stub(:save).with(any_args).and_return(true)\r
442         ResourcePicture.any_instance.stub(:store_picture).with(@mgk).and_return(true)\r
443         ResourcePicture.any_instance.stub(:to_gif?).with(any_args).and_return(true)\r
444         class GifMgk < Mgk ; end  #store_pictureは二回呼び出される。区別をつけるために\r
445         @gifmgk = GifMgk.new      #パラメータを二種類用意する。\r
446         ResourcePicture.stub(:png_to_gif).with(any_args).and_return(@gifmgk)
447         ResourcePicture.any_instance.stub(:store_picture).with(@gifmgk).and_return(false)\r
448       end
449       it 'Falseを返す' do
450         res = @rp.store(@mgk)\r
451         res.should be_false\r
452       end\r
453     end
454   end\r
455   
456   describe '画像ファイルの作成・更新に於いて' do\r
457     #PictureIo経由で画像を保存するための機能。ファイル名に自身のidを使うので事前に自身の保存が必要。\r
458     before do
459       PictureIO.resource_picture_io.class.stub(:subdirs).with(any_args).and_return(['', 'v', 'h', 'vh', 'thumbnail'])\r
460       ResourcePicture.any_instance.stub(:h).with(any_args).and_return('data')
461       ResourcePicture.any_instance.stub(:v).with(any_args).and_return('data')
462       ResourcePicture.any_instance.stub(:vh).with(any_args).and_return('data')
463       ResourcePicture.any_instance.stub(:thumbnail).with(any_args).and_return('data')
464       @op = Factory :original_picture, :artist_id => @artist.id, :license_id => @license.id
465       @rp = Factory :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id
466     end
467     context '事前チェック' do
468       before do
469         #すべての処理を正常パターンで通過させ、保存機能をチェックする。
470         PictureIO.resource_picture_io.stub(:put).with(any_args).and_return(true)
471       end
472       it '画像ファイルの保存が5回呼ばれる' do\r
473         PictureIO.resource_picture_io.should_receive(:put).with(any_args).exactly(5)
474         res = @rp.store_picture(Mgk.new)\r
475       end\r
476       it '画像ファイルのベースへの保存が1回呼ばれる' do\r
477         PictureIO.resource_picture_io.should_receive(:put).with('data', @rp.filename, '').exactly(1)
478         res = @rp.store_picture(Mgk.new)\r
479       end\r
480       it '画像ファイルの垂直反転への保存が1回呼ばれる' do\r
481         PictureIO.resource_picture_io.should_receive(:put).with('data', @rp.filename, 'v').exactly(1)
482         res = @rp.store_picture(Mgk.new)\r
483       end\r
484       it '画像ファイルの水平反転への保存が1回呼ばれる' do\r
485         PictureIO.resource_picture_io.should_receive(:put).with('data', @rp.filename, 'h').exactly(1)
486         res = @rp.store_picture(Mgk.new)\r
487       end\r
488       it '画像ファイルの垂直水平反転への保存が1回呼ばれる' do\r
489         PictureIO.resource_picture_io.should_receive(:put).with('data', @rp.filename, 'vh').exactly(1)
490         res = @rp.store_picture(Mgk.new)\r
491       end\r
492       it '画像ファイルのサムネイルへの保存が1回呼ばれる' do\r
493         PictureIO.resource_picture_io.should_receive(:put).with('data', @rp.filename, 'thumbnail').exactly(1)
494         res = @rp.store_picture(Mgk.new)\r
495       end\r
496       it '垂直反転が1回呼ばれる' do\r
497         ResourcePicture.any_instance.should_receive(:v).with(any_args).exactly(1)
498         res = @rp.store_picture(Mgk.new)\r
499       end\r
500       it '水平反転が1回呼ばれる' do\r
501         ResourcePicture.any_instance.should_receive(:h).with(any_args).exactly(1)
502         res = @rp.store_picture(Mgk.new)\r
503       end\r
504       it '垂直水平反転が1回呼ばれる' do\r
505         ResourcePicture.any_instance.should_receive(:vh).with(any_args).exactly(1)
506         res = @rp.store_picture(Mgk.new)\r
507       end\r
508       it 'サムネイル化が1回呼ばれる' do\r
509         ResourcePicture.any_instance.should_receive(:thumbnail).with(any_args).exactly(1)
510         res = @rp.store_picture(Mgk.new)\r
511       end\r
512     end
513     context 'つつがなく終わるとき' do
514       before do
515         #すべての処理を正常パターンで通過させ、保存機能をチェックする。\r
516         PictureIO.resource_picture_io.stub(:put).with(any_args).and_return(true)
517       end
518       it 'Trueを返す' do
519         res = @rp.store_picture(Mgk.new)\r
520         res.should be_true\r
521       end\r
522     end
523     context '例外ケース' do
524       before do
525         PictureIO.resource_picture_io.stub(:put).with(any_args).and_return(false)
526       end
527       it 'Falseを返す' do
528         res = @rp.store_picture(Mgk.new)\r
529         res.should be_false\r
530       end\r
531     end
532     
533   end
534   
535 describe 'サムネイル変換に於いて' do
536     #サムネイル化した画像データを返すが、スタブをおくので、リサイズと画像データ化を試みるかをチェックする
537     before do
538       ResourcePicture.stub(:resize).with(any_args).and_return(Mgk.new)
539       @rp = Factory :resource_picture, :artist_id => @artist.id, :license_id => @license.id
540     end
541     it 'サムネイルサイズに縮小した画像データを返す' do\r
542       ResourcePicture.should_receive(:resize).with(any_args).exactly(1)
543       @rp.thumbnail(Mgk.new)\r
544     end\r
545     it 'データが返る' do\r
546       #全体スタブより\r
547       @rp.thumbnail(Mgk.new).should eq 'data'\r
548     end\r
549   end
550   
551   describe '垂直反転変換に於いて' do
552     #垂直反転した画像データを返すが、スタブをおくので、反転と画像データ化を試みるかをチェックする
553     before do
554       Mgk.any_instance.stub(:flip).with(any_args).and_return(Mgk.new)
555       @rp = Factory :resource_picture, :artist_id => @artist.id, :license_id => @license.id
556     end\r
557     it '垂直反転する' do\r
558       Mgk.any_instance.should_receive(:flip).exactly(1)
559       @rp.v(Mgk.new)\r
560     end\r
561     it '画像データ化する' do\r
562       Mgk.any_instance.should_receive(:to_blob).exactly(1)
563       @rp.v(Mgk.new)\r
564     end\r
565     it 'データが返る' do\r
566       #全体スタブより\r
567       @rp.v(Mgk.new).should eq 'data'\r
568     end\r
569   end
570   
571   describe '水平反転変換に於いて' do
572     #水平反転した画像データを返すが、スタブをおくので、反転と画像データ化を試みるかをチェックする
573     before do
574       Mgk.any_instance.stub(:flop).with(any_args).and_return(Mgk.new)
575       @rp = Factory :resource_picture, :artist_id => @artist.id, :license_id => @license.id
576     end
577     it '水平反転する' do\r
578       Mgk.any_instance.should_receive(:flop).exactly(1)
579       @rp.h(Mgk.new)\r
580     end\r
581     it '画像データ化する' do\r
582       Mgk.any_instance.should_receive(:to_blob).exactly(1)
583       @rp.h(Mgk.new)\r
584     end\r
585     it 'データが返る' do\r
586       #全体スタブより\r
587       @rp.h(Mgk.new).should eq 'data'\r
588     end\r
589   end
590   
591   describe '垂直水平反転変換に於いて' do
592     #垂直水平反転した画像データを返すが、スタブをおくので、反転と画像データ化を試みるかをチェックする
593     before do
594       Mgk.any_instance.stub(:flip).with(any_args).and_return(Mgk.new)
595       Mgk.any_instance.stub(:flop).with(any_args).and_return(Mgk.new)
596       @rp = Factory :resource_picture, :artist_id => @artist.id, :license_id => @license.id
597     end
598     it '垂直反転する' do\r
599       Mgk.any_instance.should_receive(:flip).exactly(1)
600       @rp.vh(Mgk.new)\r
601     end\r
602     it '水平反転する' do\r
603       Mgk.any_instance.should_receive(:flop).exactly(1)
604       @rp.vh(Mgk.new)\r
605     end\r
606     it '画像データ化する' do\r
607       Mgk.any_instance.should_receive(:to_blob).exactly(1)
608       @rp.vh(Mgk.new)\r
609     end\r
610     it 'データが返る' do\r
611       #全体スタブより\r
612       @rp.vh(Mgk.new).should eq 'data'\r
613     end\r
614   end
615   
616 end
617 \r