diff options
| author | Markus Roberts <Markus@reality.com> | 2010-06-28 16:32:11 -0700 |
|---|---|---|
| committer | Markus Roberts <Markus@reality.com> | 2010-06-28 16:32:11 -0700 |
| commit | 9ceb4540a567b0a9de85af5397df4a292303a9c3 (patch) | |
| tree | 30d1e1601888381baaaa14bfc5ee7246fd5c78e8 /spec/unit/parser/ast/function_spec.rb | |
| parent | 85638cf427fe9b35d3e3b0fa4ce919c5806c60d3 (diff) | |
| download | puppet-9ceb4540a567b0a9de85af5397df4a292303a9c3.tar.gz puppet-9ceb4540a567b0a9de85af5397df4a292303a9c3.tar.xz puppet-9ceb4540a567b0a9de85af5397df4a292303a9c3.zip | |
[#3994-part 2] rename integration tests to *_spec.rb
Some spec files like active_record.rb had names that would confuse the
load path and get loaded instead of the intended implentation when the
spec was run from the same directory as the file.
Author: Matt Robinson <matt@puppetlabs.com>
Date: Fri Jun 11 15:29:33 2010 -0700
Diffstat (limited to 'spec/unit/parser/ast/function_spec.rb')
| -rw-r--r-- | spec/unit/parser/ast/function_spec.rb | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/spec/unit/parser/ast/function_spec.rb b/spec/unit/parser/ast/function_spec.rb deleted file mode 100644 index bb687eac0..000000000 --- a/spec/unit/parser/ast/function_spec.rb +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + '/../../../spec_helper' - -describe Puppet::Parser::AST::Function do - before :each do - @scope = mock 'scope' - end - - describe "when initializing" do - it "should not fail if the function doesn't exist" do - Puppet::Parser::Functions.stubs(:function).returns(false) - - lambda{ Puppet::Parser::AST::Function.new :name => "dontexist" }.should_not raise_error(Puppet::ParseError) - - end - end - - it "should return its representation with to_s" do - args = stub 'args', :is_a? => true, :to_s => "[a, b]" - - Puppet::Parser::AST::Function.new(:name => "func", :arguments => args).to_s.should == "func(a, b)" - end - - describe "when evaluating" do - - it "should fail if the function doesn't exist" do - Puppet::Parser::Functions.stubs(:function).returns(false) - func = Puppet::Parser::AST::Function.new :name => "dontexist" - - lambda{ func.evaluate(@scope) }.should raise_error(Puppet::ParseError) - end - - it "should fail if the function is a statement used as rvalue" do - Puppet::Parser::Functions.stubs(:function).with("exist").returns(true) - Puppet::Parser::Functions.stubs(:rvalue?).with("exist").returns(false) - - func = Puppet::Parser::AST::Function.new :name => "exist", :ftype => :rvalue - - lambda{ func.evaluate(@scope) }.should raise_error(Puppet::ParseError, "Function 'exist' does not return a value") - end - - it "should fail if the function is an rvalue used as statement" do - Puppet::Parser::Functions.stubs(:function).with("exist").returns(true) - Puppet::Parser::Functions.stubs(:rvalue?).with("exist").returns(true) - - func = Puppet::Parser::AST::Function.new :name => "exist", :ftype => :statement - - lambda{ func.evaluate(@scope) }.should raise_error(Puppet::ParseError,"Function 'exist' must be the value of a statement") - end - - it "should evaluate its arguments" do - argument = stub 'arg' - Puppet::Parser::Functions.stubs(:function).with("exist").returns(true) - func = Puppet::Parser::AST::Function.new :name => "exist", :ftype => :statement, :arguments => argument - @scope.stubs(:function_exist) - - argument.expects(:safeevaluate).with(@scope).returns("argument") - - func.evaluate(@scope) - end - - it "should call the underlying ruby function" do - argument = stub 'arg', :safeevaluate => "nothing" - Puppet::Parser::Functions.stubs(:function).with("exist").returns(true) - func = Puppet::Parser::AST::Function.new :name => "exist", :ftype => :statement, :arguments => argument - - @scope.expects(:function_exist).with("nothing") - - func.evaluate(@scope) - end - - it "should return the ruby function return for rvalue functions" do - argument = stub 'arg', :safeevaluate => "nothing" - Puppet::Parser::Functions.stubs(:function).with("exist").returns(true) - func = Puppet::Parser::AST::Function.new :name => "exist", :ftype => :statement, :arguments => argument - @scope.stubs(:function_exist).with("nothing").returns("returning") - - func.evaluate(@scope).should == "returning" - end - - end -end |
