Update stdlib
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / intersection_spec.rb
index 6361304..ec368a5 100755 (executable)
@@ -1,19 +1,22 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the intersection function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("intersection")).to eq("function_intersection")
-  end
-
-  it "should raise a ParseError if there are fewer than 2 arguments" do
-    expect { scope.function_intersection([]) }.to( raise_error(Puppet::ParseError) )
-  end
-
-  it "should return the intersection of two arrays" do
-    result = scope.function_intersection([["a","b","c"],["b","c","d"]])
-    expect(result).to(eq(["b","c"]))
-  end
+describe 'intersection' 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('one').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([], []).and_return([]) }
+  it { is_expected.to run.with_params([], ['one']).and_return([]) }
+  it { is_expected.to run.with_params(['one'], []).and_return([]) }
+  it { is_expected.to run.with_params(['one'], ['one']).and_return(['one']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three']).and_return(['two', 'three']) }
+  it { is_expected.to run.with_params(['ōŋể', 'ŧשợ', 'ţђŕẽё'], ['ŧשợ', 'ţђŕẽё']).and_return(['ŧשợ', 'ţђŕẽё']) }
+  it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['two', 'three']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['two', 'three']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three', 'four']).and_return(['two', 'three']) }
+  it 'should not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return([]) end
 end