1 #! /usr/bin/env ruby -S rspec
4 describe "the is_float function" do
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
8 expect(Puppet::Parser::Functions.function("is_float")).to eq("function_is_float")
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))
15 it "should return true if a float" do
16 result = scope.function_is_float(["0.12"])
17 expect(result).to(eq(true))
20 it "should return false if a string" do
21 result = scope.function_is_float(["asdf"])
22 expect(result).to(eq(false))
25 it "should return false if an integer" do
26 result = scope.function_is_float(["3"])
27 expect(result).to(eq(false))
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))