aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators/app_generator_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/generators/app_generator_test.rb')
-rw-r--r--railties/test/generators/app_generator_test.rb22
1 files changed, 15 insertions, 7 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