source: other-projects/hathitrust/vagrant-solr-cluster/trunk/modules/stdlib/spec/functions/squeeze_spec.rb@ 30960

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

Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1require 'spec_helper'
2
3describe 'squeeze' 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 { is_expected.to run.with_params('', '', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
7 it { is_expected.to run.with_params(1).and_raise_error(NoMethodError) }
8 it { is_expected.to run.with_params({}).and_raise_error(NoMethodError) }
9 it { is_expected.to run.with_params(true).and_raise_error(NoMethodError) }
10
11 context 'when squeezing a single string' do
12 it { is_expected.to run.with_params('').and_return('') }
13 it { is_expected.to run.with_params('a').and_return('a') }
14 it { is_expected.to run.with_params('aaaaaaaaa').and_return('a') }
15 it { is_expected.to run.with_params('aaaaaaaaa', 'a').and_return('a') }
16 it { is_expected.to run.with_params('aaaaaaaaabbbbbbbbbbcccccccccc', 'b-c').and_return('aaaaaaaaabc') }
17 end
18
19 context 'when squeezing values in an array' do
20 it {
21 is_expected.to run \
22 .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc']) \
23 .and_return( ['', 'a', 'a', 'abc'])
24 }
25 it {
26 is_expected.to run \
27 .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc'], 'a') \
28 .and_return( ['', 'a', 'a', 'abbbbbbbbbbcccccccccc'])
29 }
30 it {
31 is_expected.to run \
32 .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc'], 'b-c') \
33 .and_return( ['', 'a', 'aaaaaaaaa', 'aaaaaaaaabc'])
34 }
35 end
36
37 context 'when using a class extending String' do
38 it 'should call its squeeze method' do
39 value = AlsoString.new('aaaaaaaaa')
40 value.expects(:squeeze).returns('foo')
41 expect(subject).to run.with_params(value).and_return('foo')
42 end
43 end
44end
Note: See TracBrowser for help on using the repository browser.