X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Fspec%2Ffunctions%2Fbool2num_spec.rb;h=7402f3a9f6a427aabaccd858e7810292e69aa8d9;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hp=3904d7e404214fe6e04a6906031060e05fbc0af0;hpb=ad88f67c13ae0f1a08936dad643f1e3509ab5f40;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/spec/functions/bool2num_spec.rb b/3rdparty/modules/stdlib/spec/functions/bool2num_spec.rb old mode 100755 new mode 100644 index 3904d7e40..7402f3a9f --- a/3rdparty/modules/stdlib/spec/functions/bool2num_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/bool2num_spec.rb @@ -1,38 +1,18 @@ -#! /usr/bin/env ruby -S rspec require 'spec_helper' -describe "the bool2num function" do - let(:scope) { PuppetlabsSpec::PuppetInternals.scope } +describe 'bool2num' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it "should exist" do - expect(Puppet::Parser::Functions.function("bool2num")).to eq("function_bool2num") + [true, 'true', 't', '1', 'y', 'yes', AlsoString.new('true')].each do |truthy| + it { is_expected.to run.with_params(truthy).and_return(1) } end - it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_bool2num([]) }.to( raise_error(Puppet::ParseError)) + [false, 'false', 'f', '0', 'n', 'no', AlsoString.new('false')].each do |falsey| + it { is_expected.to run.with_params(falsey).and_return(0) } end - it "should convert true to 1" do - result = scope.function_bool2num([true]) - expect(result).to(eq(1)) - end - - it "should convert 'true' to 1" do - result = scope.function_bool2num(['true']) - result.should(eq(1)) - end - - it "should convert 'false' to 0" do - result = scope.function_bool2num(['false']) - expect(result).to(eq(0)) - end - - it "should accept objects which extend String" do - class AlsoString < String - end - - value = AlsoString.new('true') - result = scope.function_bool2num([value]) - result.should(eq(1)) + [[], 10, 'invalid', 1.0].each do |falsey| + it { is_expected.to run.with_params(falsey).and_raise_error(Puppet::ParseError) } end end