Add missing new files from commit 131e09855e06
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / to_json_spec.rb
1 require 'spec_helper'
2
3 describe 'to_json' do
4   it { is_expected.not_to eq(nil) }
5   it { is_expected.to run.with_params('').and_return('""') }
6   it { is_expected.to run.with_params(true).and_return('true') }
7   it { is_expected.to run.with_params('one').and_return('"one"') }
8   it { is_expected.to run.with_params([]).and_return('[]') }
9   it { is_expected.to run.with_params(['one']).and_return('["one"]') }
10   it { is_expected.to run.with_params(['one', 'two']).and_return('["one","two"]') }
11   it { is_expected.to run.with_params({}).and_return('{}') }
12   it { is_expected.to run.with_params('key' => 'value').and_return('{"key":"value"}') }
13   it {
14     is_expected.to run.with_params('one' => { 'oneA' => 'A', 'oneB' => { 'oneB1' => '1', 'oneB2' => '2' } }, 'two' => ['twoA', 'twoB'])
15                       .and_return('{"one":{"oneA":"A","oneB":{"oneB1":"1","oneB2":"2"}},"two":["twoA","twoB"]}')
16   }
17
18   it { is_expected.to run.with_params('‰').and_return('"‰"') }
19   it { is_expected.to run.with_params('竹').and_return('"竹"') }
20   it { is_expected.to run.with_params('Ü').and_return('"Ü"') }
21   it { is_expected.to run.with_params('∇').and_return('"∇"') }
22 end