Sha256: 195c51568d176711d3eb44f4236d092d7ff9a4789f929de931c760b2587b4016

Contents?: true

Size: 737 Bytes

Versions: 304

Compression:

Stored size: 737 Bytes

Contents

require 'spec_helper'

describe "the scanf function" do
  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

304 entries across 304 versions & 1 rubygems

Version Path
puppet-8.3.0 spec/unit/parser/functions/scanf_spec.rb
puppet-8.3.0-x86-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-8.3.0-x64-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-8.3.0-universal-darwin spec/unit/parser/functions/scanf_spec.rb
puppet-8.4.0 spec/unit/parser/functions/scanf_spec.rb
puppet-8.4.0-x86-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-8.4.0-x64-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-8.4.0-universal-darwin spec/unit/parser/functions/scanf_spec.rb
puppet-7.28.0 spec/unit/parser/functions/scanf_spec.rb
puppet-7.28.0-x86-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-7.28.0-x64-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-7.28.0-universal-darwin spec/unit/parser/functions/scanf_spec.rb
puppet-8.3.1 spec/unit/parser/functions/scanf_spec.rb
puppet-8.3.1-x86-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-8.3.1-x64-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-8.3.1-universal-darwin spec/unit/parser/functions/scanf_spec.rb
puppet-7.27.0 spec/unit/parser/functions/scanf_spec.rb
puppet-7.27.0-x86-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-7.27.0-x64-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-7.27.0-universal-darwin spec/unit/parser/functions/scanf_spec.rb