| 1 | require 'spec_helper'
|
|---|
| 2 |
|
|---|
| 3 | describe 'swapcase' do
|
|---|
| 4 | it { is_expected.not_to eq(nil) }
|
|---|
| 5 | it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
|
|---|
| 6 | it {
|
|---|
| 7 | pending("Current implementation ignores parameters after the first.")
|
|---|
| 8 | is_expected.to run.with_params('a', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
|
|---|
| 9 | }
|
|---|
| 10 | it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
|
|---|
| 11 | it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
|
|---|
| 12 | it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
|
|---|
| 13 | describe 'with strings as inputs' do
|
|---|
| 14 | it { is_expected.to run.with_params('').and_return('') }
|
|---|
| 15 | it { is_expected.to run.with_params('one').and_return('ONE') }
|
|---|
| 16 | it { is_expected.to run.with_params('ONE').and_return('one') }
|
|---|
| 17 | it { is_expected.to run.with_params('oNe').and_return('OnE') }
|
|---|
| 18 | end
|
|---|
| 19 | describe 'with arrays as inputs' do
|
|---|
| 20 | it { is_expected.to run.with_params([]).and_return([]) }
|
|---|
| 21 | describe 'only containing strings' do
|
|---|
| 22 | it { is_expected.to run.with_params(['']).and_return(['']) }
|
|---|
| 23 | it { is_expected.to run.with_params(['one']).and_return(['ONE']) }
|
|---|
| 24 | it { is_expected.to run.with_params(['ONE']).and_return(['one']) }
|
|---|
| 25 | it { is_expected.to run.with_params(['oNe']).and_return(['OnE']) }
|
|---|
| 26 | it { is_expected.to run.with_params(['one', 'ONE']).and_return(['ONE', 'one']) }
|
|---|
| 27 | it { is_expected.to run.with_params(['ONE', 'OnE']).and_return(['one', 'oNe']) }
|
|---|
| 28 | it { is_expected.to run.with_params(['oNe', 'one']).and_return(['OnE', 'ONE']) }
|
|---|
| 29 | end
|
|---|
| 30 | describe 'containing mixed types' do
|
|---|
| 31 | it { is_expected.to run.with_params(['OnE', {}]).and_return(['oNe', {}]) }
|
|---|
| 32 | it { is_expected.to run.with_params(['OnE', 1]).and_return(['oNe', 1]) }
|
|---|
| 33 | it { is_expected.to run.with_params(['OnE', []]).and_return(['oNe', []]) }
|
|---|
| 34 | it { is_expected.to run.with_params(['OnE', ['two']]).and_return(['oNe', ['two']]) }
|
|---|
| 35 | end
|
|---|
| 36 | end
|
|---|
| 37 | it "should accept objects which extend String" do
|
|---|
| 38 | is_expected.to run.with_params(AlsoString.new("OnE")).and_return('oNe')
|
|---|
| 39 | end
|
|---|
| 40 | end
|
|---|