diff options
author | Hunter Haugen <hunter@puppetlabs.com> | 2015-06-01 13:36:25 -0700 |
---|---|---|
committer | Hunter Haugen <hunter@puppetlabs.com> | 2015-06-01 13:36:25 -0700 |
commit | a383705fdb133978e53503b7e01012367fac139d (patch) | |
tree | f044a3b9c65db499ae279a08328c18200201d094 /spec/functions/member_spec.rb | |
parent | 1ae9058518d042ea81d42f46cebbb040b35a2b4d (diff) | |
parent | 18d4c21418e8d188ae659a92ff3a8df04d711f6a (diff) | |
download | puppet-stdlib-a383705fdb133978e53503b7e01012367fac139d.tar.gz puppet-stdlib-a383705fdb133978e53503b7e01012367fac139d.tar.bz2 |
Merge pull request #464 from DavidS/modules-1882-convert-to-rspec
(MODULES-1882) convert function tests to rspec-puppet
Diffstat (limited to 'spec/functions/member_spec.rb')
-rwxr-xr-x | spec/functions/member_spec.rb | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/spec/functions/member_spec.rb b/spec/functions/member_spec.rb index 1a1d7c6..527f887 100755 --- a/spec/functions/member_spec.rb +++ b/spec/functions/member_spec.rb @@ -1,34 +1,21 @@ -#! /usr/bin/env ruby -S rspec require 'spec_helper' -describe "the member function" do - let(:scope) { PuppetlabsSpec::PuppetInternals.scope } - - it "should exist" do - expect(Puppet::Parser::Functions.function("member")).to eq("function_member") - end - - it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_member([]) }.to( raise_error(Puppet::ParseError)) - end - - it "should return true if a member is in an array" do - result = scope.function_member([["a","b","c"], "a"]) - expect(result).to(eq(true)) - end - - it "should return false if a member is not in an array" do - result = scope.function_member([["a","b","c"], "d"]) - expect(result).to(eq(false)) - end - - it "should return true if a member array is in an array" do - result = scope.function_member([["a","b","c"], ["a", "b"]]) - expect(result).to(eq(true)) - end - - it "should return false if a member array is not in an array" do - result = scope.function_member([["a","b","c"], ["d", "e"]]) - expect(result).to(eq(false)) - end +describe 'member' 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 first.") + is_expected.to run.with_params([], [], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) + } + it { is_expected.to run.with_params([], '').and_return(false) } + it { is_expected.to run.with_params([], ['']).and_return(false) } + it { is_expected.to run.with_params([''], '').and_return(true) } + it { is_expected.to run.with_params([''], ['']).and_return(true) } + it { is_expected.to run.with_params([], 'one').and_return(false) } + it { is_expected.to run.with_params([], ['one']).and_return(false) } + it { is_expected.to run.with_params(['one'], 'one').and_return(true) } + it { is_expected.to run.with_params(['one'], ['one']).and_return(true) } + it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'two']).and_return(true) } + it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'five']).and_return(false) } end |