Mercurial > repos > other > Puppet
comparison modules/stdlib/spec/functions/chop_spec.rb @ 272:c42fb28cff86
Update to a newer Python module
This also pulls in an EPEL module (which we don't use) and a newer
stdlib version.
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 03 Jan 2020 19:56:04 +0000 |
parents | addb0ea390a1 |
children | d9352a684e62 |
comparison
equal
deleted
inserted
replaced
271:c62728474654 | 272:c42fb28cff86 |
---|---|
1 #! /usr/bin/env ruby -S rspec | |
2 require 'spec_helper' | 1 require 'spec_helper' |
3 | 2 |
4 describe "the chop function" do | 3 describe 'chop' do |
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope } | 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(1).and_raise_error(Puppet::ParseError) } | |
7 it { | |
8 pending('Current implementation ignores parameters after the first.') | |
9 is_expected.to run.with_params('a', 'b').and_raise_error(Puppet::ParseError) | |
10 } | |
11 it { is_expected.to run.with_params('one').and_return('on') } | |
12 it { is_expected.to run.with_params("one\n").and_return('one') } | |
13 it { is_expected.to run.with_params("one\n\n").and_return("one\n") } | |
14 it { is_expected.to run.with_params(%W[one\n two three\n]).and_return(%w[one tw three]) } | |
6 | 15 |
7 it "should exist" do | 16 it { is_expected.to run.with_params(AlsoString.new('one')).and_return('on') } |
8 expect(Puppet::Parser::Functions.function("chop")).to eq("function_chop") | 17 it { is_expected.to run.with_params(AlsoString.new("one\n")).and_return('one') } |
9 end | 18 it { is_expected.to run.with_params(AlsoString.new("one\n\n")).and_return("one\n") } |
19 it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new('two'), "three\n"]).and_return(%w[one tw three]) } | |
10 | 20 |
11 it "should raise a ParseError if there is less than 1 arguments" do | 21 context 'with UTF8 and double byte characters' do |
12 expect { scope.function_chop([]) }.to( raise_error(Puppet::ParseError)) | 22 it { is_expected.to run.with_params("ůťƒ8\n\n").and_return("ůťƒ8\n") } |
13 end | 23 it { is_expected.to run.with_params("ネット\n\n").and_return("ネット\n") } |
14 | |
15 it "should chop the end of a string" do | |
16 result = scope.function_chop(["asdf\n"]) | |
17 expect(result).to(eq("asdf")) | |
18 end | |
19 | |
20 it "should accept objects which extend String" do | |
21 class AlsoString < String | |
22 end | |
23 | |
24 value = AlsoString.new("abc\n") | |
25 result = scope.function_chop([value]) | |
26 result.should(eq('abc')) | |
27 end | 24 end |
28 end | 25 end |