summaryrefslogtreecommitdiffstats
path: root/spec/integration/parser/parser.rb
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-06-28 16:32:11 -0700
committerMarkus Roberts <Markus@reality.com>2010-06-28 16:32:11 -0700
commit9ceb4540a567b0a9de85af5397df4a292303a9c3 (patch)
tree30d1e1601888381baaaa14bfc5ee7246fd5c78e8 /spec/integration/parser/parser.rb
parent85638cf427fe9b35d3e3b0fa4ce919c5806c60d3 (diff)
downloadpuppet-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/integration/parser/parser.rb')
-rwxr-xr-xspec/integration/parser/parser.rb113
1 files changed, 0 insertions, 113 deletions
diff --git a/spec/integration/parser/parser.rb b/spec/integration/parser/parser.rb
deleted file mode 100755
index ee476c02f..000000000
--- a/spec/integration/parser/parser.rb
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../spec_helper'
-
-describe Puppet::Parser::Parser do
- module ParseMatcher
- class ParseAs
- def initialize(klass)
- @parser = Puppet::Parser::Parser.new "development"
- @class = klass
- end
-
- def result_instance
- @result.hostclass("").code[0]
- end
-
- def matches?(string)
- @string = string
- @result = @parser.parse(string)
- return result_instance.instance_of?(@class)
- end
-
- def description
- "parse as a #{@class}"
- end
-
- def failure_message
- " expected #{@string} to parse as #{@class} but was #{result_instance.class}"
- end
-
- def negative_failure_message
- " expected #{@string} not to parse as #{@class}"
- end
- end
-
- def parse_as(klass)
- ParseAs.new(klass)
- end
-
- class ParseWith
- def initialize(block)
- @parser = Puppet::Parser::Parser.new "development"
- @block = block
- end
-
- def result_instance
- @result.hostclass("").code[0]
- end
-
- def matches?(string)
- @string = string
- @result = @parser.parse(string)
- return @block.call(result_instance)
- end
-
- def description
- "parse with the block evaluating to true"
- end
-
- def failure_message
- " expected #{@string} to parse with a true result in the block"
- end
-
- def negative_failure_message
- " expected #{@string} not to parse with a true result in the block"
- end
- end
-
- def parse_with(&block)
- ParseWith.new(block)
- end
- end
-
- include ParseMatcher
-
- before :each do
- @resource_type_collection = Puppet::Resource::TypeCollection.new("env")
- @parser = Puppet::Parser::Parser.new "development"
- end
-
- describe "when parsing comments before statement" do
- it "should associate the documentation to the statement AST node" do
- ast = @parser.parse("""
- # comment
- class test {}
- """)
-
- ast.hostclass("test").doc.should == "comment\n"
- end
- end
-
- describe "when parsing" do
- it "should be able to parse normal left to right relationships" do
- "Notify[foo] -> Notify[bar]".should parse_as(Puppet::Parser::AST::Relationship)
- end
-
- it "should be able to parse right to left relationships" do
- "Notify[foo] <- Notify[bar]".should parse_as(Puppet::Parser::AST::Relationship)
- end
-
- it "should be able to parse normal left to right subscriptions" do
- "Notify[foo] ~> Notify[bar]".should parse_as(Puppet::Parser::AST::Relationship)
- end
-
- it "should be able to parse right to left subscriptions" do
- "Notify[foo] <~ Notify[bar]".should parse_as(Puppet::Parser::AST::Relationship)
- end
-
- it "should correctly set the arrow type of a relationship" do
- "Notify[foo] <~ Notify[bar]".should parse_with { |rel| rel.arrow == "<~" }
- end
- end
-end