summaryrefslogtreecommitdiff
path: root/spec/functions/count_spec.rb
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2017-01-13 12:41:58 +0100
committervarac <varacanero@zeromail.org>2017-01-13 12:41:58 +0100
commit066c08f8362d53f0f30897cb8710d11260c726ea (patch)
treea6369eecd88bb731fe413d0bbc8af73d74d1f447 /spec/functions/count_spec.rb
parent71123634744b9fe2ec7d6a3e38e9789fd84801e3 (diff)
parentb65dd1f45d10e10e45455358aeabb29167990e2c (diff)
Merge remote-tracking branch 'origin/master' into leap_master
Diffstat (limited to 'spec/functions/count_spec.rb')
-rwxr-xr-xspec/functions/count_spec.rb43
1 files changed, 15 insertions, 28 deletions
diff --git a/spec/functions/count_spec.rb b/spec/functions/count_spec.rb
index f8f1d48..c8d1960 100755
--- a/spec/functions/count_spec.rb
+++ b/spec/functions/count_spec.rb
@@ -1,31 +1,18 @@
-#! /usr/bin/env ruby -S rspec
-
require 'spec_helper'
-describe "the count function" do
- let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
- it "should exist" do
- expect(Puppet::Parser::Functions.function("count")).to eq("function_count")
- end
-
- it "should raise a ArgumentError if there is more than 2 arguments" do
- expect { scope.function_count(['foo', 'bar', 'baz']) }.to( raise_error(ArgumentError))
- end
-
- it "should be able to count arrays" do
- expect(scope.function_count([["1","2","3"]])).to(eq(3))
- end
-
- it "should be able to count matching elements in arrays" do
- expect(scope.function_count([["1", "2", "2"], "2"])).to(eq(2))
- end
-
- it "should not count nil or empty strings" do
- expect(scope.function_count([["foo","bar",nil,""]])).to(eq(2))
- end
-
- it 'does not count an undefined hash key or an out of bound array index (which are both :undef)' do
- expect(scope.function_count([["foo",:undef,:undef]])).to eq(1)
- end
+describe 'count' do
+ it { is_expected.not_to eq(nil) }
+ it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
+ it { is_expected.to run.with_params("one").and_raise_error(ArgumentError) }
+ it { is_expected.to run.with_params("one", "two").and_return(1) }
+ it {
+ pending("should actually be like this, and not like above")
+ is_expected.to run.with_params("one", "two").and_raise_error(ArgumentError)
+ }
+ it { is_expected.to run.with_params("one", "two", "three").and_raise_error(ArgumentError) }
+ it { is_expected.to run.with_params(["one", "two", "three"]).and_return(3) }
+ it { is_expected.to run.with_params(["one", "two", "two"], "two").and_return(2) }
+ it { is_expected.to run.with_params(["one", nil, "two"]).and_return(2) }
+ it { is_expected.to run.with_params(["one", "", "two"]).and_return(2) }
+ it { is_expected.to run.with_params(["one", :undef, "two"]).and_return(2) }
end