source: other-projects/hathitrust/vagrant-hadoop-cluster/trunk/modules/stdlib/spec/functions/delete_spec.rb@ 30903

Last change on this file since 30903 was 30903, checked in by davidb, 7 years ago

Vagrant provisioning files for a 4-node Hadoop cluster. See README.txt for more details

  • Property svn:executable set to *
File size: 3.5 KB
Line 
1require 'spec_helper'
2
3describe 'delete' do
4 it { is_expected.not_to eq(nil) }
5 it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
6 it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) }
7 it { is_expected.to run.with_params([], 'two') }
8 it { is_expected.to run.with_params([], 'two', 'three').and_raise_error(Puppet::ParseError) }
9 it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError) }
10
11 describe 'deleting from an array' do
12 it { is_expected.to run.with_params([], '').and_return([]) }
13 it { is_expected.to run.with_params([], 'two').and_return([]) }
14 it { is_expected.to run.with_params(['two'], 'two').and_return([]) }
15 it { is_expected.to run.with_params(['two', 'two'], 'two').and_return([]) }
16 it { is_expected.to run.with_params(['ab', 'b', 'c', 'b'], 'b').and_return(['ab', 'c']) }
17 it { is_expected.to run.with_params(['one', 'two', 'three'], 'four').and_return(['one', 'two', 'three']) }
18 it { is_expected.to run.with_params(['one', 'two', 'three'], 'e').and_return(['one', 'two', 'three']) }
19 it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['one', 'three']) }
20 it { is_expected.to run.with_params(['two', 'one', 'two', 'three', 'two'], 'two').and_return(['one', 'three']) }
21 it { is_expected.to run.with_params(['one', 'two', 'three', 'two'], ['one', 'two']).and_return(['three']) }
22 end
23
24 describe 'deleting from a string' do
25 it { is_expected.to run.with_params('', '').and_return('') }
26 it { is_expected.to run.with_params('bar', '').and_return('bar') }
27 it { is_expected.to run.with_params('', 'bar').and_return('') }
28 it { is_expected.to run.with_params('bar', 'bar').and_return('') }
29 it { is_expected.to run.with_params('barbar', 'bar').and_return('') }
30 it { is_expected.to run.with_params('barfoobar', 'bar').and_return('foo') }
31 it { is_expected.to run.with_params('foobarbabarz', 'bar').and_return('foobaz') }
32 it { is_expected.to run.with_params('foobarbabarz', ['foo', 'bar']).and_return('baz') }
33 # this is so sick
34 it { is_expected.to run.with_params('barfoobar', ['barbar', 'foo']).and_return('barbar') }
35 it { is_expected.to run.with_params('barfoobar', ['foo', 'barbar']).and_return('') }
36 end
37
38 describe 'deleting from an array' do
39 it { is_expected.to run.with_params({}, '').and_return({}) }
40 it { is_expected.to run.with_params({}, 'key').and_return({}) }
41 it { is_expected.to run.with_params({'key' => 'value'}, 'key').and_return({}) }
42 it { is_expected.to run \
43 .with_params({'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}, 'key2') \
44 .and_return( {'key1' => 'value1', 'key3' => 'value3'})
45 }
46 it { is_expected.to run \
47 .with_params({'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}, ['key1', 'key2']) \
48 .and_return( {'key3' => 'value3'})
49 }
50 end
51
52 it "should leave the original array intact" do
53 argument1 = ['one','two','three']
54 original1 = argument1.dup
55 result = subject.call([argument1,'two'])
56 expect(argument1).to eq(original1)
57 end
58 it "should leave the original string intact" do
59 argument1 = 'onetwothree'
60 original1 = argument1.dup
61 result = subject.call([argument1,'two'])
62 expect(argument1).to eq(original1)
63 end
64 it "should leave the original hash intact" do
65 argument1 = {'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}
66 original1 = argument1.dup
67 result = subject.call([argument1,'key2'])
68 expect(argument1).to eq(original1)
69 end
70end
Note: See TracBrowser for help on using the repository browser.