Sha256: bbc264f80a57a387dd8241aeefc2ea06b52288e34fd10e4b20d4a70c9f166a80

Contents?: true

Size: 810 Bytes

Versions: 36

Compression:

Stored size: 810 Bytes

Contents

require 'spec_helper'

describe "the scanf function" do
  before :all do
    Puppet::Parser::Functions.autoloader.loadall
  end

  let(:node) { Puppet::Node.new('localhost') }
  let(:compiler) { Puppet::Parser::Compiler.new(node) }
  let(:scope) { Puppet::Parser::Scope.new(compiler) }

  it 'scans a value and returns an array' do
    expect(scope.function_scanf(['42', '%i'])[0] == 42)
  end

  it 'returns empty array if nothing was scanned' do
    expect(scope.function_scanf(['no', '%i']) == [])
  end

  it 'produces result up to first unsuccessful scan' do
    expect(scope.function_scanf(['42 no', '%i'])[0] == 42)
  end

  it 'errors when not given enough arguments' do
    expect do
      scope.function_scanf(['42'])
    end.to raise_error(/.*scanf\(\): Wrong number of arguments given/m)
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
puppet-5.5.22 spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.22-x86-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.22-x64-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.22-universal-darwin spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.21 spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.21-x86-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.21-x64-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.21-universal-darwin spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.20 spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.20-x86-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.20-x64-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.20-universal-darwin spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.19 spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.19-x86-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.19-x64-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.19-universal-darwin spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.18 spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.18-x86-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.18-x64-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-5.5.18-universal-darwin spec/unit/parser/functions/scanf_spec.rb