diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-17 03:20:30 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-17 03:20:30 +0530 |
commit | b04230e3bbf912d60601e9e7b797c4cd43581d51 (patch) | |
tree | 97a2f784a2ec2bfae4f960af56a9280dad6f7774 /railties/test/generators | |
parent | 867829b187969607aa12f2b0457f25da9c204db0 (diff) | |
parent | 6e3bee6cf1f0d2684152292db0a8b757249824fd (diff) | |
download | rails-b04230e3bbf912d60601e9e7b797c4cd43581d51.tar.gz rails-b04230e3bbf912d60601e9e7b797c4cd43581d51.tar.bz2 rails-b04230e3bbf912d60601e9e7b797c4cd43581d51.zip |
Merge remote branch 'mainstream/master'
Conflicts:
actionpack/lib/action_controller/metal/flash.rb
Diffstat (limited to 'railties/test/generators')
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 22 | ||||
-rw-r--r-- | railties/test/generators/generators_test_helper.rb | 6 |
2 files changed, 19 insertions, 9 deletions
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 7dd798db75..62ea07f14e 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -55,13 +55,19 @@ class AppGeneratorTest < GeneratorsTestCase end def test_invalid_application_name_raises_an_error - content = capture(:stderr){ Rails::Generators::AppGenerator.start [File.join(destination_root, "43-things")] } + content = capture(:stderr){ run_generator [File.join(destination_root, "43-things")] } assert_equal "Invalid application name 43-things. Please give a name which does not start with numbers.\n", content end def test_invalid_application_name_is_fixed - silence(:stdout){ Rails::Generators::AppGenerator.start [File.join(destination_root, "things-43")] } - assert_file "things-43/config/environment.rb", /Things43::Application/ + run_generator [File.join(destination_root, "things-43")] + assert_file "things-43/config/environment.rb", /Things43::Application\.initialize!/ + assert_file "things-43/config/application.rb", /^module Things43$/ + end + + def test_application_names_are_not_singularized + run_generator [File.join(destination_root, "hats")] + assert_file "hats/config/environment.rb", /Hats::Application\.initialize!/ end def test_config_database_is_added_by_default @@ -138,7 +144,7 @@ class AppGeneratorTest < GeneratorsTestCase template = %{ say "It works!" } template.instance_eval "def read; self; end" # Make the string respond to read - generator([destination_root], :template => path, :database => "sqlite3").expects(:open).with(path).returns(template) + generator([destination_root], :template => path).expects(:open).with(path).returns(template) assert_match /It works!/, silence(:stdout){ generator.invoke } end @@ -162,14 +168,16 @@ class AppGeneratorTest < GeneratorsTestCase end def test_dev_option - run_generator [destination_root, "--dev"] + generator([destination_root], :dev => true).expects(:run).with("gem bundle") + silence(:stdout){ generator.invoke } rails_path = File.expand_path('../../..', Rails.root) - dev_gem = %(gem "rails", :path => #{rails_path.inspect}) + dev_gem = %(directory #{rails_path.inspect}, :glob => "{*/,}*.gemspec") assert_file 'Gemfile', /^#{Regexp.escape(dev_gem)}$/ end def test_edge_option - run_generator [destination_root, "--edge"] + generator([destination_root], :edge => true).expects(:run).with("gem bundle") + silence(:stdout){ generator.invoke } edge_gem = %(gem "rails", :git => "git://github.com/rails/rails.git") assert_file 'Gemfile', /^#{Regexp.escape(edge_gem)}$/ end diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb index fcd0989fd7..54953b76c8 100644 --- a/railties/test/generators/generators_test_helper.rb +++ b/railties/test/generators/generators_test_helper.rb @@ -1,5 +1,3 @@ -# TODO: Fix this RAILS_ENV stuff -RAILS_ENV = 'test' unless defined?(RAILS_ENV) require 'abstract_unit' module Rails @@ -25,4 +23,8 @@ class GeneratorsTestCase < Rails::Generators::TestCase rescue # Do nothing. end + + def test_truth + # Don't cry test/unit + end end
\ No newline at end of file |