37
|
1 #! /usr/bin/env ruby -S rspec
|
|
2 require 'spec_helper'
|
|
3
|
|
4 describe "the is_float function" do
|
|
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
|
7 it "should exist" do
|
|
8 expect(Puppet::Parser::Functions.function("is_float")).to eq("function_is_float")
|
|
9 end
|
|
10
|
|
11 it "should raise a ParseError if there is less than 1 arguments" do
|
|
12 expect { scope.function_is_float([]) }.to( raise_error(Puppet::ParseError))
|
|
13 end
|
|
14
|
|
15 it "should return true if a float" do
|
|
16 result = scope.function_is_float(["0.12"])
|
|
17 expect(result).to(eq(true))
|
|
18 end
|
|
19
|
|
20 it "should return false if a string" do
|
|
21 result = scope.function_is_float(["asdf"])
|
|
22 expect(result).to(eq(false))
|
|
23 end
|
|
24
|
|
25 it "should return false if an integer" do
|
|
26 result = scope.function_is_float(["3"])
|
|
27 expect(result).to(eq(false))
|
|
28 end
|
|
29 it "should return true if a float is created from an arithmetical operation" do
|
|
30 result = scope.function_is_float([3.2*2])
|
|
31 expect(result).to(eq(true))
|
|
32 end
|
|
33 end
|