# split function not accept by puppet

Hi,

I got below error when I rspec-puppet

 /opt/puppetlabs/puppet/bin/bundle exec rake spec

Puppet::PreformattedError:
Evaluation Error: Error while evaluating a Function Call, 'split' parameter 'str' expects a String value, got Undef at /root/modules_new/module_name/spec/fixtures/modules/module_name/manifests/params.pp:29:17 on node.


when I open the code it contain.

class module_name::params{

$tmp1 = split($::blockdevices, ',')
$tmp2 = grep($tmp1, 'sd')
$count =count(tmp2) }  The code take the node disk count. below is my gem list /opt/puppetlabs/puppet/bin/gem list bigdecimal (1.2.4) bundle (0.0.1) bundler (1.12.5) hiera (3.0.5) puppet (4.3.1) puppet_forge (2.1.1) r10k (2.1.1) rake (10.1.0) rdoc (4.1.0) rest-client (1.6.9) rugged (0.21.4) semantic_puppet (0.1.0) stomp (1.3.3) test-unit (2.1.7.0)  edit retag close merge delete ## 1 Answer Sort by » oldest newest most voted Looks like the fact$::blockdevices is undefined causing split to throw an error. Since you are using rspec you need to explicitly define every fact you use.

See the following for an example of defining facts in a spec file: https://github.com/puppetlabs/puppetl...

Also you can try this out on the Puppet REPL if you just want to test the function.

more