From 5cf934eab50cae0b375713a0af7b5f2a2904ff45 Mon Sep 17 00:00:00 2001 From: Stefan Sprenger Date: Wed, 25 May 2011 15:03:07 +0200 Subject: Add test files to engine's gemspec --- .../lib/rails/generators/rails/plugin_new/templates/%name%.gemspec | 3 +++ railties/test/generators/plugin_new_generator_test.rb | 7 +++++++ 2 files changed, 10 insertions(+) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec b/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec index 15299ddb9f..56b06829d8 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +++ b/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec @@ -5,5 +5,8 @@ Gem::Specification.new do |s| s.summary = "Insert <%= camelized %> summary." s.description = "Insert <%= camelized %> description." s.files = Dir["{app,config,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"] +<% unless options.skip_test_unit? -%> + s.test_files = Dir["test/**/*"] +<% end -%> s.version = "0.0.1" end diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb index 1b01c9dbc1..05ce11a730 100644 --- a/railties/test/generators/plugin_new_generator_test.rb +++ b/railties/test/generators/plugin_new_generator_test.rb @@ -173,6 +173,7 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase run_generator assert_file "bukkits.gemspec", /s.name = "bukkits"/ assert_file "bukkits.gemspec", /s.files = Dir\["\{app,config,lib\}\/\*\*\/\*"\]/ + assert_file "bukkits.gemspec", /s.test_files = Dir\["test\/\*\*\/\*"\]/ assert_file "bukkits.gemspec", /s.version = "0.0.1"/ end @@ -195,6 +196,12 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase assert_no_file "test" end + def test_skipping_test_unit + run_generator [destination_root, "--skip-test-unit"] + assert_no_file "test" + assert_no_match(/s.test_files = Dir\["test\/\*\*\/\*"\]/, File.read(File.join(destination_root, "bukkits.gemspec"))) + end + def test_skipping_gemspec run_generator [destination_root, "--skip-gemspec"] assert_no_file "bukkits.gemspec" -- cgit v1.2.3 From 360b98f0618873e5c0a41f0a5e029868b8deadf9 Mon Sep 17 00:00:00 2001 From: Stefan Sprenger Date: Wed, 25 May 2011 15:03:42 +0200 Subject: Remove whitespaces from empty line --- railties/test/generators/plugin_new_generator_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb index 05ce11a730..269b2c8687 100644 --- a/railties/test/generators/plugin_new_generator_test.rb +++ b/railties/test/generators/plugin_new_generator_test.rb @@ -188,7 +188,7 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase assert_file "spec/dummy/config/application.rb" assert_no_file "test/dummy" end - + def test_creating_dummy_without_tests_but_with_dummy_path run_generator [destination_root, "--dummy_path", "spec/dummy", "--skip-test-unit"] assert_file "spec/dummy" -- cgit v1.2.3 From 22be5ca8b91b1ee8bf2aeb8ae29a64a45968ac24 Mon Sep 17 00:00:00 2001 From: Stefan Sprenger Date: Wed, 25 May 2011 15:12:54 +0200 Subject: Improve test assertion --- railties/test/generators/plugin_new_generator_test.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb index 269b2c8687..b93e33f61a 100644 --- a/railties/test/generators/plugin_new_generator_test.rb +++ b/railties/test/generators/plugin_new_generator_test.rb @@ -199,7 +199,9 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase def test_skipping_test_unit run_generator [destination_root, "--skip-test-unit"] assert_no_file "test" - assert_no_match(/s.test_files = Dir\["test\/\*\*\/\*"\]/, File.read(File.join(destination_root, "bukkits.gemspec"))) + assert_file "bukkits.gemspec" do |contents| + assert_no_match /s.test_files = Dir\["test\/\*\*\/\*"\]/, contents + end end def test_skipping_gemspec -- cgit v1.2.3