Permalink
Browse files

Generated cleaning scripts now reference libs in gem

  • Loading branch information...
1 parent 321a779 commit 35795815c681bc224a904717d8b4a8187a88a46b @bobbyno committed Sep 22, 2009
View
@@ -24,8 +24,8 @@ app_generators/ruby/templates/test_io.rb
app_generators/ruby/templates/test_right_triangle.rb
bin/shubox
cleaner_generators/test_unit_cleaner/USAGE
+cleaner_generators/test_unit_cleaner/lib/test_unit_cleaner.rb
cleaner_generators/test_unit_cleaner/templates/clean_test_unit
-cleaner_generators/test_unit_cleaner/templates/test_unit_cleaner.rb
cleaner_generators/test_unit_cleaner/test_unit_cleaner_generator.rb
lib/languages.rb
lib/shubox.rb
@@ -10,7 +10,7 @@ def run(args)
dir = ARGV.first
files = Dir["#{dir}/test/**/test_*.rb"].each do |file|
- unless file.match /test_helper.rb/
+ unless file.match(/test_helper.rb/)
puts "cleaning: #{file}"
clean(file)
end
@@ -39,13 +39,8 @@ def clean(filename)
end
def usage
- <<-EOS
-USAGE: test_unit_cleaner path/to/file
-
-Deletes the method bodies from all tests in the specified file.
-If file is a directory, all tests in the directory matching the
-pattern path/to/file/test/**/test_*.rb will be affected.
- EOS
+ usage_file = File.dirname(__FILE__) + "/../USAGE"
+ return File.readlines(usage_file)
end
end
end
@@ -1,5 +1,12 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/test_unit_cleaner'
+begin
+ require 'shubox'
+rescue LoadError
+ require 'rubygems'
+ require 'shubox'
+end
+
+require 'test_unit_cleaner/lib/test_unit_cleaner'
Shubox::TestUnitCleaner.new.run(ARGV)
@@ -11,7 +11,6 @@ def manifest
record do |m|
m.directory 'script'
m.template "clean_test_unit", "script/clean_test_unit", script_options
- m.file "test_unit_cleaner.rb", "script/test_unit_cleaner.rb"
end
end
View
@@ -1,6 +1,11 @@
$:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
+$:.unshift(File.dirname(__FILE__) + '/../cleaner_generators') unless
+ $:.include?(File.dirname(__FILE__) + '/../cleaner_generators') || $:.include?(File.expand_path(File.dirname(__FILE__) + '../cleaner_generators'))
+
module Shubox
VERSION = '0.8'
-end
+end
+
+require 'test_unit_cleaner/lib/test_unit_cleaner'
View
@@ -14,7 +14,7 @@ to start coding: A directory structure, some classes and unit tests to get start
s.email = ["codeculturist@gmail.com"]
s.executables = ["shubox"]
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "app_generators/ruby/templates/file.txt", "README.rdoc"]
- s.files = ["History.txt", "MIT-LICENSE", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "app_generators/java/USAGE", "app_generators/java/java_generator.rb", "app_generators/java/templates/Greeting.java", "app_generators/java/templates/GreetingTest.java", "app_generators/java/templates/build.xml", "app_generators/java/templates/lib/hamcrest-core.jar", "app_generators/java/templates/lib/junit.jar", "app_generators/java/templates/project.iml", "app_generators/java/templates/project.ipr", "app_generators/ruby/USAGE", "app_generators/ruby/ruby_generator.rb", "app_generators/ruby/templates/file.txt", "app_generators/ruby/templates/rakefile.rb", "app_generators/ruby/templates/right_triangle.rb", "app_generators/ruby/templates/shubox.rb", "app_generators/ruby/templates/test_helper.rb", "app_generators/ruby/templates/test_io.rb", "app_generators/ruby/templates/test_right_triangle.rb", "bin/shubox", "cleaner_generators/test_unit_cleaner/USAGE", "cleaner_generators/test_unit_cleaner/templates/clean_test_unit", "cleaner_generators/test_unit_cleaner/templates/test_unit_cleaner.rb", "cleaner_generators/test_unit_cleaner/test_unit_cleaner_generator.rb", "lib/languages.rb", "lib/shubox.rb", "lib/shubox_app_generator.rb", "script/console", "script/destroy", "script/generate", "test/test_generator_helper.rb", "test/test_helper.rb", "test/test_java_generator.rb", "test/test_languages.rb", "test/test_ruby_generator.rb", "test/test_test_unit_cleaner.rb"]
+ s.files = ["History.txt", "MIT-LICENSE", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "app_generators/java/USAGE", "app_generators/java/java_generator.rb", "app_generators/java/templates/Greeting.java", "app_generators/java/templates/GreetingTest.java", "app_generators/java/templates/build.xml", "app_generators/java/templates/lib/hamcrest-core.jar", "app_generators/java/templates/lib/junit.jar", "app_generators/java/templates/project.iml", "app_generators/java/templates/project.ipr", "app_generators/ruby/USAGE", "app_generators/ruby/ruby_generator.rb", "app_generators/ruby/templates/file.txt", "app_generators/ruby/templates/rakefile.rb", "app_generators/ruby/templates/right_triangle.rb", "app_generators/ruby/templates/shubox.rb", "app_generators/ruby/templates/test_helper.rb", "app_generators/ruby/templates/test_io.rb", "app_generators/ruby/templates/test_right_triangle.rb", "bin/shubox", "cleaner_generators/test_unit_cleaner/USAGE", "cleaner_generators/test_unit_cleaner/lib/test_unit_cleaner.rb", "cleaner_generators/test_unit_cleaner/templates/clean_test_unit", "cleaner_generators/test_unit_cleaner/test_unit_cleaner_generator.rb", "lib/languages.rb", "lib/shubox.rb", "lib/shubox_app_generator.rb", "script/console", "script/destroy", "script/generate", "test/test_generator_helper.rb", "test/test_helper.rb", "test/test_java_generator.rb", "test/test_languages.rb", "test/test_ruby_generator.rb", "test/test_test_unit_cleaner.rb"]
s.homepage = %q{http://github.com/bobbyno/shubox/tree/master}
s.post_install_message = %q{PostInstall.txt}
s.rdoc_options = ["--main", "README.rdoc"]
@@ -27,7 +27,6 @@ def test_generator_without_options
assert_generated_file "test/test_io.rb"
assert_generated_file "test/test_helper.rb"
assert_generated_file "script/clean_test_unit"
- assert_generated_file "script/test_unit_cleaner.rb"
run_generated_build_script("rake")
end
@@ -1,5 +1,5 @@
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
-require File.join(File.dirname(__FILE__), '..', 'cleaner_generators', 'test_unit_cleaner', 'templates', 'test_unit_cleaner')
+require File.join(File.dirname(__FILE__), '..', 'cleaner_generators', 'test_unit_cleaner', 'lib', 'test_unit_cleaner')
require 'fileutils'
require 'languages'
@@ -14,6 +14,11 @@ def setup
def teardown
bare_teardown
end
+
+ def test_display_usage_with_no_args
+ usage = Shubox::TestUnitCleaner.new.usage
+ assert_not_nil(usage)
+ end
def test_cleaner_without_options
run_generator('test_unit_cleaner', [APP_ROOT], sources)

0 comments on commit 3579581

Please sign in to comment.