OSDN Git Service

t#30200:update i18n devise
[pettanr/pettanr.git] / spec / models / speech_spec.rb
1 # -*- encoding: utf-8 -*-\r
2 require 'spec_helper'\r
3 \r
4 describe Speech do\r
5   before do\r
6     @admin = FactoryGirl.create :admin\r
7     @sp = FactoryGirl.create :system_picture\r
8     @lg = FactoryGirl.create :license_group\r
9     @l = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id\r
10     @user = FactoryGirl.create( :user_yas)\r
11     @author = FactoryGirl.create :author, :user_id => @user.id\r
12     \r
13     @panel = FactoryGirl.create :panel\r
14     @speech_balloon_template = FactoryGirl.create :speech_balloon_template\r
15     @speech_balloon = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
16   end\r
17   \r
18   describe '検証に於いて' do\r
19     before do\r
20       @speech = FactoryGirl.build :speech, :speech_balloon_id => @speech_balloon.id\r
21     end\r
22     \r
23     context 'オーソドックスなデータのとき' do\r
24       it '下限データが通る' do\r
25         @speech.x = 0\r
26         @speech.y = 0\r
27         @speech.width = 1\r
28         @speech.height = 1\r
29         @speech.should be_valid\r
30       end\r
31       it '上限データが通る' do\r
32         @speech.x = 99999\r
33         @speech.y = 99999\r
34         @speech.width = 99999\r
35         @speech.height = 99999\r
36         @speech.should be_valid\r
37       end\r
38     end\r
39     \r
40     context 'speech_balloon_idを検証するとき' do\r
41       #ネストの保存はnilを許可しなければならないので数値チェックだけ\r
42       it 'テストデータの確認' do\r
43         @speech.speech_balloon_id = @speech_balloon.id\r
44         @speech.should be_valid\r
45       end\r
46       it '数値でなければ失敗する' do\r
47         @speech.speech_balloon_id = 'a'\r
48         @speech.should_not be_valid\r
49       end\r
50     end\r
51     context 'contentを検証するとき' do\r
52     end\r
53     context 'xを検証するとき' do\r
54       it 'nullなら失敗する' do\r
55         @speech.x = nil\r
56         @speech.should_not be_valid\r
57       end\r
58       it '数値でなければ失敗する' do\r
59         @speech.x = 'a'\r
60         @speech.should_not be_valid\r
61       end\r
62       it '0なら通る' do\r
63         @speech.x = '0'\r
64         @speech.should be_valid\r
65       end\r
66       it '負でも通る' do\r
67         @speech.x = -1\r
68         @speech.should be_valid\r
69       end\r
70     end\r
71     context 'yを検証するとき' do\r
72       it 'nullなら失敗する' do\r
73         @speech.y = nil\r
74         @speech.should_not be_valid\r
75       end\r
76       it '数値でなければ失敗する' do\r
77         @speech.y = 'a'\r
78         @speech.should_not be_valid\r
79       end\r
80       it '0なら通る' do\r
81         @speech.y = '0'\r
82         @speech.should be_valid\r
83       end\r
84       it '負でも通る' do\r
85         @speech.y = -1\r
86         @speech.should be_valid\r
87       end\r
88     end\r
89     context 'widthを検証するとき' do\r
90       it 'nullなら失敗する' do\r
91         @speech.width = nil\r
92         @speech.should_not be_valid\r
93       end\r
94       it '数値でなければ失敗する' do\r
95         @speech.width = 'a'\r
96         @speech.should_not be_valid\r
97       end\r
98       it '0なら失敗する' do\r
99         @speech.width = '0'\r
100         @speech.should_not be_valid\r
101       end\r
102       it '負でも失敗する' do\r
103         @speech.width = -1\r
104         @speech.should_not be_valid\r
105       end\r
106     end\r
107     context 'heightを検証するとき' do\r
108       it 'nullなら失敗する' do\r
109         @speech.height = nil\r
110         @speech.should_not be_valid\r
111       end\r
112       it '数値でなければ失敗する' do\r
113         @speech.height = 'a'\r
114         @speech.should_not be_valid\r
115       end\r
116       it '0なら失敗する' do\r
117         @speech.height = '0'\r
118         @speech.should_not be_valid\r
119       end\r
120       it '負でも失敗する' do\r
121         @speech.height = -1\r
122         @speech.should_not be_valid\r
123       end\r
124     end\r
125     context 'settingsを検証するとき' do\r
126     end\r
127   end\r
128   \r
129 end\r