|
1 | | -#! /usr/bin/env ruby -S rspec |
2 | 1 | require 'spec_helper' |
3 | 2 |
|
4 | | -describe "the any2array function" do |
5 | | - let(:scope) { PuppetlabsSpec::PuppetInternals.scope } |
6 | | - |
7 | | - it "should exist" do |
8 | | - expect(Puppet::Parser::Functions.function("any2array")).to eq("function_any2array") |
9 | | - end |
10 | | - |
11 | | - it "should return an empty array if there is less than 1 argument" do |
12 | | - result = scope.function_any2array([]) |
13 | | - expect(result).to(eq([])) |
14 | | - end |
15 | | - |
16 | | - it "should convert boolean true to [ true ] " do |
17 | | - result = scope.function_any2array([true]) |
18 | | - expect(result).to(eq([true])) |
19 | | - end |
20 | | - |
21 | | - it "should convert one object to [object]" do |
22 | | - result = scope.function_any2array(['one']) |
23 | | - expect(result).to(eq(['one'])) |
24 | | - end |
25 | | - |
26 | | - it "should convert multiple objects to [objects]" do |
27 | | - result = scope.function_any2array(['one', 'two']) |
28 | | - expect(result).to(eq(['one', 'two'])) |
29 | | - end |
30 | | - |
31 | | - it "should return empty array it was called with" do |
32 | | - result = scope.function_any2array([[]]) |
33 | | - expect(result).to(eq([])) |
34 | | - end |
35 | | - |
36 | | - it "should return one-member array it was called with" do |
37 | | - result = scope.function_any2array([['string']]) |
38 | | - expect(result).to(eq(['string'])) |
39 | | - end |
40 | | - |
41 | | - it "should return multi-member array it was called with" do |
42 | | - result = scope.function_any2array([['one', 'two']]) |
43 | | - expect(result).to(eq(['one', 'two'])) |
44 | | - end |
45 | | - |
46 | | - it "should return members of a hash it was called with" do |
47 | | - result = scope.function_any2array([{ 'key' => 'value' }]) |
48 | | - expect(result).to(eq(['key', 'value'])) |
49 | | - end |
50 | | - |
51 | | - it "should return an empty array if it was called with an empty hash" do |
52 | | - result = scope.function_any2array([{ }]) |
53 | | - expect(result).to(eq([])) |
54 | | - end |
| 3 | +describe "any2array" do |
| 4 | + it { is_expected.not_to eq(nil) } |
| 5 | + it { is_expected.to run.with_params().and_return([]) } |
| 6 | + it { is_expected.to run.with_params(true).and_return([true]) } |
| 7 | + it { is_expected.to run.with_params('one').and_return(['one']) } |
| 8 | + it { is_expected.to run.with_params('one', 'two').and_return(['one', 'two']) } |
| 9 | + it { is_expected.to run.with_params([]).and_return([]) } |
| 10 | + it { is_expected.to run.with_params(['one']).and_return(['one']) } |
| 11 | + it { is_expected.to run.with_params(['one', 'two']).and_return(['one', 'two']) } |
| 12 | + it { is_expected.to run.with_params({}).and_return([]) } |
| 13 | + it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['key', 'value']) } |
| 14 | + it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['key', 'value']) } |
55 | 15 | end |
0 commit comments