From f3e79ddcd56a221c7799b35efde7e9803a5c7923 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Mon, 1 Jun 2015 12:21:59 +0100 Subject: Convert tests to use plain rspec-puppet Tests in the new style produces the following documentation output: abs should not eq nil should run abs() and raise an Puppet::ParseError should run abs(-34) and return 34 should run abs("-34") and return 34 should run abs(34) and return 34 should run abs("34") and return 34 --- spec/functions/camelcase_spec.rb | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'spec/functions/camelcase_spec.rb') diff --git a/spec/functions/camelcase_spec.rb b/spec/functions/camelcase_spec.rb index 70382ad..c78aa62 100755 --- a/spec/functions/camelcase_spec.rb +++ b/spec/functions/camelcase_spec.rb @@ -1,24 +1,17 @@ -#! /usr/bin/env ruby -S rspec require 'spec_helper' -describe "the camelcase function" do - let(:scope) { PuppetlabsSpec::PuppetInternals.scope } - - it "should exist" do - expect(Puppet::Parser::Functions.function("camelcase")).to eq("function_camelcase") - end - - it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_camelcase([]) }.to( raise_error(Puppet::ParseError)) - end - - it "should capitalize the beginning of a normal string" do - result = scope.function_camelcase(["abc"]) - expect(result).to(eq("Abc")) - end - - it "should camelcase an underscore-delimited string" do - result = scope.function_camelcase(["aa_bb_cc"]) - expect(result).to(eq("AaBbCc")) - end +describe 'camelcase' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params("abc").and_return("Abc") } + it { is_expected.to run.with_params("aa_bb_cc").and_return("AaBbCc") } + it { is_expected.to run.with_params("_aa__bb__cc_").and_return("AaBbCc") } + it { is_expected.to run.with_params("100").and_return("100") } + it { is_expected.to run.with_params("1_00").and_return("100") } + it { is_expected.to run.with_params("_").and_return("") } + it { is_expected.to run.with_params("").and_return("") } + it { is_expected.to run.with_params([]).and_return([]) } + it { is_expected.to run.with_params(["abc", "aa_bb_cc"]).and_return(["Abc", "AaBbCc"]) } + it { is_expected.to run.with_params(["abc", 1, "aa_bb_cc"]).and_return(["Abc", 1, "AaBbCc"]) } end -- cgit v1.2.3