summaryrefslogtreecommitdiffstats
path: root/autotest
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:05:07 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:05:07 -0700
commit184132e07fc1461555cb4da842df15f32842a843 (patch)
tree67085c1100b28991ee3b5f4745d67777acf8d075 /autotest
parent9ee56f2e67be973da49b1d3f21de1bf87de35e6f (diff)
downloadpuppet-184132e07fc1461555cb4da842df15f32842a843.tar.gz
puppet-184132e07fc1461555cb4da842df15f32842a843.tar.xz
puppet-184132e07fc1461555cb4da842df15f32842a843.zip
Code smell: Use {} for % notation delimiters wherever practical
* * Replaced 16 occurances of %([qQrwWx])\((.*?)\) with %\1{\2} 3 Examples: The code: # %r(/) != /\// becomes: # %r{/} != /\// The code: ri = glob(%w(bin/*.rb sbin/* lib/**/*.rb)).reject { |e| e=~ /\.(bat|cmd)$/ } becomes: ri = glob(%w{bin/*.rb sbin/* lib/**/*.rb}).reject { |e| e=~ /\.(bat|cmd)$/ } The code: if !FileUtils.uptodate?("/var/cache/eix", %w(/usr/bin/eix /usr/portage/metadata/timestamp)) becomes: if !FileUtils.uptodate?("/var/cache/eix", %w{/usr/bin/eix /usr/portage/metadata/timestamp}) * Replaced 12 occurances of %([qQrwWx])\[(.*?)\] with %\1{\2} 3 Examples: The code: return send(command) if %w[get backup restore].include? command becomes: return send(command) if %w{get backup restore}.include? command The code: for iv in %w[indent space space_before object_nl array_nl check_circular allow_nan max_nesting] becomes: for iv in %w{indent space space_before object_nl array_nl check_circular allow_nan max_nesting} The code: @puppetd.command_line.stubs(:args).returns(%w[--logdest /my/file]) becomes: @puppetd.command_line.stubs(:args).returns(%w{--logdest /my/file}) * Replaced no occurances of %([qQrwWx])<(.*?)> with %\1{\2} * Replaced 19 occurances of %([qQrwWx])([^{\[(<])(.*?)\2 with %\1{\3} 3 Examples: The code: at.add_mapping(%r%^lib/puppet/(.*)\.rb$%) { |filename, m| becomes: at.add_mapping(%r{^lib/puppet/(.*)\.rb$}) { |filename, m| The code: at.add_mapping(%r%^spec/(unit|integration)/.*\.rb$%) { |filename, _| becomes: at.add_mapping(%r{^spec/(unit|integration)/.*\.rb$}) { |filename, _| The code: at.add_mapping(%r!^lib/puppet\.rb$!) { |filename, _| becomes: at.add_mapping(%r{^lib/puppet\.rb$}) { |filename, _|
Diffstat (limited to 'autotest')
-rw-r--r--autotest/puppet_rspec.rb24
-rw-r--r--autotest/rspec.rb8
-rw-r--r--autotest/watcher.rb8
3 files changed, 20 insertions, 20 deletions
diff --git a/autotest/puppet_rspec.rb b/autotest/puppet_rspec.rb
index 55695000a..1504d453d 100644
--- a/autotest/puppet_rspec.rb
+++ b/autotest/puppet_rspec.rb
@@ -5,40 +5,40 @@ Autotest.add_hook :initialize do |at|
at.clear_mappings
# the libraries under lib/puppet
- at.add_mapping(%r%^lib/puppet/(.*)\.rb$%) { |filename, m|
+ at.add_mapping(%r{^lib/puppet/(.*)\.rb$}) { |filename, m|
at.files_matching %r!spec/(unit|integration)/#{m[1]}.rb!
}
# the actual spec files themselves
- at.add_mapping(%r%^spec/(unit|integration)/.*\.rb$%) { |filename, _|
+ at.add_mapping(%r{^spec/(unit|integration)/.*\.rb$}) { |filename, _|
filename
}
# force a complete re-run for all of these:
# main puppet lib
- at.add_mapping(%r!^lib/puppet\.rb$!) { |filename, _|
- at.files_matching %r!spec/(unit|integration)/.*\.rb!
+ at.add_mapping(%r{^lib/puppet\.rb$}) { |filename, _|
+ at.files_matching %r{spec/(unit|integration)/.*\.rb}
}
# the spec_helper
- at.add_mapping(%r!^spec/spec_helper\.rb$!) { |filename, _|
- at.files_matching %r!spec/(unit|integration)/.*\.rb!
+ at.add_mapping(%r{^spec/spec_helper\.rb$}) { |filename, _|
+ at.files_matching %r{spec/(unit|integration)/.*\.rb}
}
# the puppet test libraries
- at.add_mapping(%r!^test/lib/puppettest/.*!) { |filename, _|
- at.files_matching %r!spec/(unit|integration)/.*\.rb!
+ at.add_mapping(%r{^test/lib/puppettest/.*}) { |filename, _|
+ at.files_matching %r{spec/(unit|integration)/.*\.rb}
}
# the puppet spec libraries
- at.add_mapping(%r!^spec/lib/spec.*!) { |filename, _|
- at.files_matching %r!spec/(unit|integration)/.*\.rb!
+ at.add_mapping(%r{^spec/lib/spec.*}) { |filename, _|
+ at.files_matching %r{spec/(unit|integration)/.*\.rb}
}
# the monkey patches for rspec
- at.add_mapping(%r!^spec/lib/monkey_patches/.*!) { |filename, _|
- at.files_matching %r!spec/(unit|integration)/.*\.rb!
+ at.add_mapping(%r{^spec/lib/monkey_patches/.*}) { |filename, _|
+ at.files_matching %r{spec/(unit|integration)/.*\.rb}
}
end
diff --git a/autotest/rspec.rb b/autotest/rspec.rb
index bf3d2d939..89978d866 100644
--- a/autotest/rspec.rb
+++ b/autotest/rspec.rb
@@ -3,14 +3,14 @@ require 'autotest'
Autotest.add_hook :initialize do |at|
at.clear_mappings
# watch out: Ruby bug (1.8.6):
- # %r(/) != /\//
- at.add_mapping(%r%^spec/.*\.rb$%) { |filename, _|
+ # %r{/} != /\//
+ at.add_mapping(%r{^spec/.*\.rb$}) { |filename, _|
filename
}
- at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
+ at.add_mapping(%r{^lib/(.*)\.rb$}) { |_, m|
["spec/#{m[1]}_spec.rb"]
}
- at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) {
+ at.add_mapping(%r{^spec/(spec_helper|shared/.*)\.rb$}) {
at.files_matching %r{^spec/.*_spec\.rb$}
}
end
diff --git a/autotest/watcher.rb b/autotest/watcher.rb
index 028d3fe7d..0beaca7c6 100644
--- a/autotest/watcher.rb
+++ b/autotest/watcher.rb
@@ -98,15 +98,15 @@ def run_suite
end
watch('spec/spec_helper.rb') { run_all_specs }
-watch(%r%^spec/(unit|integration)/.*\.rb$%) { |md| run_spec_files(md[0]) }
-watch(%r%^lib/puppet/(.*)\.rb$%) { |md|
+watch(%r{^spec/(unit|integration)/.*\.rb$}) { |md| run_spec_files(md[0]) }
+watch(%r{^lib/puppet/(.*)\.rb$}) { |md|
run_spec_files(file2specs(md[0]))
if t = file2test(md[0])
run_test_file(t)
end
}
-watch(%r!^spec/lib/spec.*!) { |md| run_all_specs }
-watch(%r!^spec/lib/monkey_patches/.*!) { |md| run_all_specs }
+watch(%r{^spec/lib/spec.*}) { |md| run_all_specs }
+watch(%r{^spec/lib/monkey_patches/.*}) { |md| run_all_specs }
watch(%r{test/.+\.rb}) { |md|
if md[0] =~ /\/lib\//
run_all_tests