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/zip_spec.rb | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) (limited to 'spec/functions/zip_spec.rb') diff --git a/spec/functions/zip_spec.rb b/spec/functions/zip_spec.rb index f265fce..abca7ee 100755 --- a/spec/functions/zip_spec.rb +++ b/spec/functions/zip_spec.rb @@ -1,31 +1,15 @@ -#! /usr/bin/env ruby -S rspec require 'spec_helper' -describe "the zip function" do - let(:scope) { PuppetlabsSpec::PuppetInternals.scope } - - it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_zip([]) }.to( raise_error(Puppet::ParseError)) - end - - it "should be able to zip an array" do - result = scope.function_zip([['1','2','3'],['4','5','6']]) - expect(result).to(eq([["1", "4"], ["2", "5"], ["3", "6"]])) - result = scope.function_zip([['1','2','3'],['4','5','6'], false]) - result.should(eq([["1", "4"], ["2", "5"], ["3", "6"]])) - end - - it "should be able to zip an array and flatten" do - result = scope.function_zip([['1','2','3'],['4','5','6'], true]) - result.should(eq(["1", "4", "2", "5", "3", "6"])) - end - - it "should accept objects which extend String for the second argument" do - class AlsoString < String - end - - value = AlsoString.new('false') - result = scope.function_zip([['1','2','3'],['4','5','6'],value]) - result.should(eq([["1", "4"], ["2", "5"], ["3", "6"]])) - end +describe 'zip' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } + it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } + it { + pending("Current implementation ignores parameters after the third.") + is_expected.to run.with_params([], [], true, []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) + } + it { is_expected.to run.with_params([], []).and_return([]) } + it { is_expected.to run.with_params([1,2,3], [4,5,6]).and_return([[1,4], [2,5], [3,6]]) } + it { is_expected.to run.with_params([1,2,3], [4,5,6], false).and_return([[1,4], [2,5], [3,6]]) } + it { is_expected.to run.with_params([1,2,3], [4,5,6], true).and_return([1, 4, 2, 5, 3, 6]) } end -- cgit v1.2.3