Sha256: ac1d2a232f326c632eae3bb87829b01c2652a6ea74e81dd85ee917aa6914a9b6

Contents?: true

Size: 1.11 KB

Versions: 92

Compression:

Stored size: 1.11 KB

Contents

#! /usr/bin/env ruby
require 'spec_helper'

describe Puppet::Parser::AST::Minus do
  before :each do
    node     = Puppet::Node.new('localhost')
    compiler = Puppet::Parser::Compiler.new(node)
    @scope   = Puppet::Parser::Scope.new(compiler)
  end

  it "should evaluate its argument" do
    value = stub "value"
    value.expects(:safeevaluate).with(@scope).returns(123)

    operator = Puppet::Parser::AST::Minus.new :value => value
    operator.evaluate(@scope)
  end

  it "should fail if argument is not a string or integer" do
    array_ast = stub 'array_ast', :safeevaluate => [2]
    operator = Puppet::Parser::AST::Minus.new :value => array_ast
    lambda { operator.evaluate(@scope) }.should raise_error
  end

  it "should work with integer as string" do
    string = stub 'string', :safeevaluate => "123"
    operator = Puppet::Parser::AST::Minus.new :value => string
    operator.evaluate(@scope).should == -123
  end

  it "should work with integers" do
    int = stub 'int', :safeevaluate => 123
    operator = Puppet::Parser::AST::Minus.new :value => int
    operator.evaluate(@scope).should == -123
  end

end

Version data entries

92 entries across 92 versions & 2 rubygems

Version Path
puppet-3.8.7 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.7-x86-mingw32 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.7-x64-mingw32 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.6 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.6-x86-mingw32 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.6-x64-mingw32 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.5 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.5-x86-mingw32 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.5-x64-mingw32 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.4 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.4-x86-mingw32 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.4-x64-mingw32 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.3 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.3-x86-mingw32 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.3-x64-mingw32 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.2 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.2-x86-mingw32 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.2-x64-mingw32 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.1 spec/unit/parser/ast/minus_spec.rb
puppet-3.8.1-x86-mingw32 spec/unit/parser/ast/minus_spec.rb