summaryrefslogtreecommitdiffstats
path: root/spec/integration/parser
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:12:17 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:12:17 -0700
commit3180b9d9b2c844dade1d361326600f7001ec66dd (patch)
tree98fe7c5ac7eb942aac9c39f019a17b0b3f5a57f4 /spec/integration/parser
parent543225970225de5697734bfaf0a6eee996802c04 (diff)
downloadpuppet-3180b9d9b2c844dade1d361326600f7001ec66dd.tar.gz
puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.tar.xz
puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.zip
Code smell: Two space indentation
Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
Diffstat (limited to 'spec/integration/parser')
-rwxr-xr-xspec/integration/parser/collector_spec.rb50
-rwxr-xr-xspec/integration/parser/compiler_spec.rb34
-rwxr-xr-xspec/integration/parser/functions/require_spec.rb74
-rwxr-xr-xspec/integration/parser/parser_spec.rb186
4 files changed, 172 insertions, 172 deletions
diff --git a/spec/integration/parser/collector_spec.rb b/spec/integration/parser/collector_spec.rb
index 4b1279e61..73273c909 100755
--- a/spec/integration/parser/collector_spec.rb
+++ b/spec/integration/parser/collector_spec.rb
@@ -5,34 +5,34 @@ require File.dirname(__FILE__) + '/../../spec_helper'
require 'puppet/parser/collector'
describe Puppet::Parser::Collector do
- before do
- @scope = Puppet::Parser::Scope.new(:compiler => Puppet::Parser::Compiler.new(Puppet::Node.new("mynode")))
+ before do
+ @scope = Puppet::Parser::Scope.new(:compiler => Puppet::Parser::Compiler.new(Puppet::Node.new("mynode")))
- @resource = Puppet::Parser::Resource.new("file", "/tmp/testing", :scope => @scope, :source => "fakesource")
- {:owner => "root", :group => "bin", :mode => "644"}.each do |param, value|
- @resource[param] = value
- end
+ @resource = Puppet::Parser::Resource.new("file", "/tmp/testing", :scope => @scope, :source => "fakesource")
+ {:owner => "root", :group => "bin", :mode => "644"}.each do |param, value|
+ @resource[param] = value
end
+ end
- def query(text)
- code = "File <| #{text} |>"
- parser = Puppet::Parser::Parser.new(@scope.compiler)
- parser.parse(code).hostclass("").code[0].query
- end
+ def query(text)
+ code = "File <| #{text} |>"
+ parser = Puppet::Parser::Parser.new(@scope.compiler)
+ parser.parse(code).hostclass("").code[0].query
+ end
- {true => [%{title == "/tmp/testing"}, %{(title == "/tmp/testing")}, %{group == bin},
- %{title == "/tmp/testing" and group == bin}, %{title == bin or group == bin},
- %{title == "/tmp/testing" or title == bin}, %{title == "/tmp/testing"},
- %{(title == "/tmp/testing" or title == bin) and group == bin}],
- false => [%{title == bin}, %{title == bin or (title == bin and group == bin)},
- %{title != "/tmp/testing"}, %{title != "/tmp/testing" and group != bin}]
- }.each do |result, ary|
- ary.each do |string|
- it "should return '#{result}' when collecting resources with '#{string}'" do
- str, code = query(string).evaluate @scope
- code.should be_instance_of(Proc)
- code.call(@resource).should == result
- end
- end
+ {true => [%{title == "/tmp/testing"}, %{(title == "/tmp/testing")}, %{group == bin},
+ %{title == "/tmp/testing" and group == bin}, %{title == bin or group == bin},
+ %{title == "/tmp/testing" or title == bin}, %{title == "/tmp/testing"},
+ %{(title == "/tmp/testing" or title == bin) and group == bin}],
+ false => [%{title == bin}, %{title == bin or (title == bin and group == bin)},
+ %{title != "/tmp/testing"}, %{title != "/tmp/testing" and group != bin}]
+ }.each do |result, ary|
+ ary.each do |string|
+ it "should return '#{result}' when collecting resources with '#{string}'" do
+ str, code = query(string).evaluate @scope
+ code.should be_instance_of(Proc)
+ code.call(@resource).should == result
+ end
end
+ end
end
diff --git a/spec/integration/parser/compiler_spec.rb b/spec/integration/parser/compiler_spec.rb
index 512924f6f..83bbf9500 100755
--- a/spec/integration/parser/compiler_spec.rb
+++ b/spec/integration/parser/compiler_spec.rb
@@ -3,27 +3,27 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe Puppet::Parser::Compiler do
- before :each do
- @node = Puppet::Node.new "testnode"
+ before :each do
+ @node = Puppet::Node.new "testnode"
- @scope_resource = stub 'scope_resource', :builtin? => true, :finish => nil, :ref => 'Class[main]'
- @scope = stub 'scope', :resource => @scope_resource, :source => mock("source")
- end
+ @scope_resource = stub 'scope_resource', :builtin? => true, :finish => nil, :ref => 'Class[main]'
+ @scope = stub 'scope', :resource => @scope_resource, :source => mock("source")
+ end
- after do
- Puppet.settings.clear
- end
+ after do
+ Puppet.settings.clear
+ end
- it "should be able to determine the configuration version from a local version control repository" do
- # This should always work, because we should always be
- # in the puppet repo when we run this.
- version = %x{git rev-parse HEAD}.chomp
+ it "should be able to determine the configuration version from a local version control repository" do
+ # This should always work, because we should always be
+ # in the puppet repo when we run this.
+ version = %x{git rev-parse HEAD}.chomp
- Puppet.settings[:config_version] = 'git rev-parse HEAD'
+ Puppet.settings[:config_version] = 'git rev-parse HEAD'
- @parser = Puppet::Parser::Parser.new "development"
- @compiler = Puppet::Parser::Compiler.new(@node)
+ @parser = Puppet::Parser::Parser.new "development"
+ @compiler = Puppet::Parser::Compiler.new(@node)
- @compiler.catalog.version.should == version
- end
+ @compiler.catalog.version.should == version
+ end
end
diff --git a/spec/integration/parser/functions/require_spec.rb b/spec/integration/parser/functions/require_spec.rb
index 3d65a50f0..8b3beefe9 100755
--- a/spec/integration/parser/functions/require_spec.rb
+++ b/spec/integration/parser/functions/require_spec.rb
@@ -3,42 +3,42 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe "The require function" do
- before :each do
- @node = Puppet::Node.new("mynode")
- @compiler = Puppet::Parser::Compiler.new(@node)
-
- @compiler.send(:evaluate_main)
- @compiler.catalog.client_version = "0.25"
- @scope = @compiler.topscope
- # preload our functions
- Puppet::Parser::Functions.function(:include)
- Puppet::Parser::Functions.function(:require)
- end
-
- it "should add a dependency between the 'required' class and our class" do
- @compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass")
-
- @scope.function_require("requiredclass")
- @scope.resource["require"].should_not be_nil
- ref = @scope.resource["require"].shift
- ref.type.should == "Class"
- ref.title.should == "Requiredclass"
- end
-
- it "should queue relationships between the 'required' class and our classes" do
- @compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass1")
- @compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass2")
-
- @scope.function_require("requiredclass1")
- @scope.function_require("requiredclass2")
-
- @scope.resource["require"].should_not be_nil
-
- (ref1,ref2) = @scope.resource["require"]
- ref1.type.should == "Class"
- ref1.title.should == "Requiredclass1"
- ref2.type.should == "Class"
- ref2.title.should == "Requiredclass2"
- end
+ before :each do
+ @node = Puppet::Node.new("mynode")
+ @compiler = Puppet::Parser::Compiler.new(@node)
+
+ @compiler.send(:evaluate_main)
+ @compiler.catalog.client_version = "0.25"
+ @scope = @compiler.topscope
+ # preload our functions
+ Puppet::Parser::Functions.function(:include)
+ Puppet::Parser::Functions.function(:require)
+ end
+
+ it "should add a dependency between the 'required' class and our class" do
+ @compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass")
+
+ @scope.function_require("requiredclass")
+ @scope.resource["require"].should_not be_nil
+ ref = @scope.resource["require"].shift
+ ref.type.should == "Class"
+ ref.title.should == "Requiredclass"
+ end
+
+ it "should queue relationships between the 'required' class and our classes" do
+ @compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass1")
+ @compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass2")
+
+ @scope.function_require("requiredclass1")
+ @scope.function_require("requiredclass2")
+
+ @scope.resource["require"].should_not be_nil
+
+ (ref1,ref2) = @scope.resource["require"]
+ ref1.type.should == "Class"
+ ref1.title.should == "Requiredclass1"
+ ref2.type.should == "Class"
+ ref2.title.should == "Requiredclass2"
+ end
end
diff --git a/spec/integration/parser/parser_spec.rb b/spec/integration/parser/parser_spec.rb
index ff81758d1..7b85bcacb 100755
--- a/spec/integration/parser/parser_spec.rb
+++ b/spec/integration/parser/parser_spec.rb
@@ -3,111 +3,111 @@
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)
- 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)
- @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
+ 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)
+ 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
- include ParseMatcher
+ def parse_as(klass)
+ ParseAs.new(klass)
+ end
- before :each do
- @resource_type_collection = Puppet::Resource::TypeCollection.new("env")
+ 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)
+ @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
- describe "when parsing comments before statement" do
- it "should associate the documentation to the statement AST node" do
- ast = @parser.parse("""
- # comment
- class test {}
- """)
+ 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
- ast.hostclass("test").doc.should == "comment\n"
- 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
+ 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 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 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 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
+ it "should correctly set the arrow type of a relationship" do
+ "Notify[foo] <~ Notify[bar]".should parse_with { |rel| rel.arrow == "<~" }
end
+ end
end