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-7.24.0 spec/unit/parser/functions/scanf_spec.rb
puppet-7.24.0-x86-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-7.24.0-x64-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-7.24.0-universal-darwin spec/unit/parser/functions/scanf_spec.rb
puppet-7.23.0 spec/unit/parser/functions/scanf_spec.rb
puppet-7.23.0-x86-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-7.23.0-x64-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-7.23.0-universal-darwin spec/unit/parser/functions/scanf_spec.rb
puppet-7.22.0 spec/unit/parser/functions/scanf_spec.rb
puppet-7.22.0-x86-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-7.22.0-x64-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-7.22.0-universal-darwin spec/unit/parser/functions/scanf_spec.rb
puppet-6.29.0 spec/unit/parser/functions/scanf_spec.rb
puppet-6.29.0-x86-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-6.29.0-x64-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-6.29.0-universal-darwin spec/unit/parser/functions/scanf_spec.rb
puppet-7.21.0 spec/unit/parser/functions/scanf_spec.rb
puppet-7.21.0-x86-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-7.21.0-x64-mingw32 spec/unit/parser/functions/scanf_spec.rb
puppet-7.21.0-universal-darwin spec/unit/parser/functions/scanf_spec.rb