Sha256: 73b8c83ae2dbb298072dc8c2c0b10eafa19bb5cee2d750716e6c65c47d3ebb68

Contents?: true

Size: 1.04 KB

Versions: 19

Compression:

Stored size: 1.04 KB

Contents

#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../../../spec_helper'

describe Puppet::Parser::AST::Minus do
  before :each do
    @scope = Puppet::Parser::Scope.new
  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

19 entries across 19 versions & 1 rubygems

Version Path
puppet-2.6.18 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.17 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.16 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.15 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.14 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.13 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.12 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.11 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.10 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.9 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.8 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.7 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.6 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.5 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.4 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.3 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.2 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.1 spec/unit/parser/ast/minus_spec.rb
puppet-2.6.0 spec/unit/parser/ast/minus_spec.rb