OSDN Git Service

fix:error dlg
[pettanr/pettanr.git] / lib / test / common_spec.rb
1 # -*- encoding: utf-8 -*-
2 #共通処理
3 require 'common'
4
5 describe JSON do
6   before do
7   end
8
9   describe '例外なしパースに於いて' do
10     context 'テキストを渡されたとき' do
11       it 'Json解析している' do
12         JSON.should_receive(:parse).with(any_args).exactly(1)
13         r = JSON.parse_no_except '{}'
14       end
15       it '単数データならHashで返す' do
16         r = JSON.parse_no_except '{}'
17         r.is_a?(Hash).should be_true
18       end
19     end
20     context 'パース失敗したとき' do
21       it 'Falseを返す' do
22         JSON.should_receive(:parse).with(any_args).and_raise('StandardError')
23         r = JSON.parse_no_except ''
24         r.should be_false
25       end
26     end
27   end
28 end
29