diff options
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/app_rails_loader_test.rb | 41 | ||||
-rw-r--r-- | railties/test/application/generators_test.rb | 2 | ||||
-rw-r--r-- | railties/test/application/rake/notes_test.rb | 8 | ||||
-rw-r--r-- | railties/test/generators/actions_test.rb | 2 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 4 | ||||
-rw-r--r-- | railties/test/generators/plugin_new_generator_test.rb | 12 | ||||
-rw-r--r-- | railties/test/generators/shared_generator_tests.rb | 4 | ||||
-rw-r--r-- | railties/test/isolation/abstract_unit.rb | 2 | ||||
-rw-r--r-- | railties/test/script_rails_loader_test.rb | 22 |
9 files changed, 57 insertions, 40 deletions
diff --git a/railties/test/app_rails_loader_test.rb b/railties/test/app_rails_loader_test.rb new file mode 100644 index 0000000000..87e0ad7bd7 --- /dev/null +++ b/railties/test/app_rails_loader_test.rb @@ -0,0 +1,41 @@ +require 'abstract_unit' +require 'rails/app_rails_loader' + +class AppRailsLoaderTest < ActiveSupport::TestCase + test "is in a rails application if bin/rails exists and contains APP_PATH" do + File.stubs(:exists?).returns(true) + File.stubs(:read).with('bin/rails').returns('APP_PATH') + assert Rails::AppRailsLoader.in_rails_application_or_engine? + end + + test "is not in a rails application if bin/rails exists but doesn't contain APP_PATH" do + File.stubs(:exists?).returns(true) + File.stubs(:read).with('bin/rails').returns('railties bin/rails') + assert !Rails::AppRailsLoader.in_rails_application_or_engine? + end + + test "is in a rails application if parent directory has bin/rails containing APP_PATH" do + File.stubs(:exists?).with("/foo/bar/bin/rails").returns(false) + File.stubs(:exists?).with("/foo/bin/rails").returns(true) + File.stubs(:read).with('/foo/bin/rails').returns('APP_PATH') + assert Rails::AppRailsLoader.in_rails_application_or_engine_subdirectory?(Pathname.new("/foo/bar")) + end + + test "is not in a rails application if at the root directory and doesn't have bin/rails" do + Pathname.any_instance.stubs(:root?).returns true + assert !Rails::AppRailsLoader.in_rails_application_or_engine? + end + + test "is in a rails engine if parent directory has bin/rails containing ENGINE_PATH" do + File.stubs(:exists?).with("/foo/bar/bin/rails").returns(false) + File.stubs(:exists?).with("/foo/bin/rails").returns(true) + File.stubs(:read).with('/foo/bin/rails').returns('ENGINE_PATH') + assert Rails::AppRailsLoader.in_rails_application_or_engine_subdirectory?(Pathname.new("/foo/bar")) + end + + test "is in a rails engine if bin/rails exists containing ENGINE_PATH" do + File.stubs(:exists?).returns(true) + File.stubs(:read).with('bin/rails').returns('ENGINE_PATH') + assert Rails::AppRailsLoader.in_rails_application_or_engine? + end +end diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb index bc0af499c1..78ada58ec8 100644 --- a/railties/test/application/generators_test.rb +++ b/railties/test/application/generators_test.rb @@ -30,7 +30,7 @@ module ApplicationTests end test "allow running plugin new generator inside Rails app directory" do - FileUtils.cd(rails_root){ `ruby script/rails plugin new vendor/plugins/bukkits` } + FileUtils.cd(rails_root){ `ruby bin/rails plugin new vendor/plugins/bukkits` } assert File.exist?(File.join(rails_root, "vendor/plugins/bukkits/test/dummy/config/application.rb")) end diff --git a/railties/test/application/rake/notes_test.rb b/railties/test/application/rake/notes_test.rb index 744bb93671..5893d58925 100644 --- a/railties/test/application/rake/notes_test.rb +++ b/railties/test/application/rake/notes_test.rb @@ -62,7 +62,6 @@ module ApplicationTests app_file "config/initializers/some_initializer.rb", "# TODO: note in config directory" app_file "db/some_seeds.rb", "# TODO: note in db directory" app_file "lib/some_file.rb", "# TODO: note in lib directory" - app_file "script/run_something.rb", "# TODO: note in script directory" app_file "test/some_test.rb", 1000.times.map { "" }.join("\n") << "# TODO: note in test directory" app_file "some_other_dir/blah.rb", "# TODO: note in some_other directory" @@ -83,11 +82,10 @@ module ApplicationTests assert_match(/note in config directory/, output) assert_match(/note in db directory/, output) assert_match(/note in lib directory/, output) - assert_match(/note in script directory/, output) assert_match(/note in test directory/, output) assert_no_match(/note in some_other directory/, output) - assert_equal 6, lines.size + assert_equal 5, lines.size lines.each do |line_number| assert_equal 4, line_number.size @@ -100,7 +98,6 @@ module ApplicationTests app_file "config/initializers/some_initializer.rb", "# TODO: note in config directory" app_file "db/some_seeds.rb", "# TODO: note in db directory" app_file "lib/some_file.rb", "# TODO: note in lib directory" - app_file "script/run_something.rb", "# TODO: note in script directory" app_file "test/some_test.rb", 1000.times.map { "" }.join("\n") << "# TODO: note in test directory" app_file "some_other_dir/blah.rb", "# TODO: note in some_other directory" @@ -121,12 +118,11 @@ module ApplicationTests assert_match(/note in config directory/, output) assert_match(/note in db directory/, output) assert_match(/note in lib directory/, output) - assert_match(/note in script directory/, output) assert_match(/note in test directory/, output) assert_match(/note in some_other directory/, output) - assert_equal 7, lines.size + assert_equal 6, lines.size lines.each do |line_number| assert_equal 4, line_number.size diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index 54734ed260..c9e9f33d4e 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -151,7 +151,7 @@ class ActionsTest < Rails::Generators::TestCase end def test_generate_should_run_script_generate_with_argument_and_options - generator.expects(:run_ruby_script).once.with('script/rails generate model MyModel', verbose: false) + generator.expects(:run_ruby_script).once.with('bin/rails generate model MyModel', verbose: false) action :generate, 'model', 'MyModel' end diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 945cb61bc1..1750149abc 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -17,6 +17,9 @@ DEFAULT_APP_FILES = %w( app/models app/models/concerns app/views/layouts + bin/bundle + bin/rails + bin/rake config/environments config/initializers config/locales @@ -26,7 +29,6 @@ DEFAULT_APP_FILES = %w( lib/tasks lib/assets log - script/rails test/fixtures test/controllers test/models diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb index ab78800a4e..4bf5a2f08b 100644 --- a/railties/test/generators/plugin_new_generator_test.rb +++ b/railties/test/generators/plugin_new_generator_test.rb @@ -209,10 +209,10 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase assert_file "app/views" assert_file "app/helpers" assert_file "app/mailers" + assert_file "bin/rails" assert_file "config/routes.rb", /Rails.application.routes.draw do/ assert_file "lib/bukkits/engine.rb", /module Bukkits\n class Engine < ::Rails::Engine\n end\nend/ assert_file "lib/bukkits.rb", /require "bukkits\/engine"/ - assert_file "script/rails" end def test_being_quiet_while_creating_dummy_application @@ -246,15 +246,15 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase def test_usage_of_engine_commands run_generator [destination_root, "--full"] - assert_file "script/rails", /ENGINE_PATH = File.expand_path\('..\/..\/lib\/bukkits\/engine', __FILE__\)/ - assert_file "script/rails", /ENGINE_ROOT = File.expand_path\('..\/..', __FILE__\)/ - assert_file "script/rails", /require 'rails\/all'/ - assert_file "script/rails", /require 'rails\/engine\/commands'/ + assert_file "bin/rails", /ENGINE_PATH = File.expand_path\('..\/..\/lib\/bukkits\/engine', __FILE__\)/ + assert_file "bin/rails", /ENGINE_ROOT = File.expand_path\('..\/..', __FILE__\)/ + assert_file "bin/rails", /require 'rails\/all'/ + assert_file "bin/rails", /require 'rails\/engine\/commands'/ end def test_shebang run_generator [destination_root, "--full"] - assert_file "script/rails", /#!\/usr\/bin\/env ruby/ + assert_file "bin/rails", /#!\/usr\/bin\/env ruby/ end def test_passing_dummy_path_as_a_parameter diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb index e4924c8386..d203afed5c 100644 --- a/railties/test/generators/shared_generator_tests.rb +++ b/railties/test/generators/shared_generator_tests.rb @@ -68,12 +68,12 @@ module SharedGeneratorTests def test_shebang_is_added_to_rails_file run_generator [destination_root, "--ruby", "foo/bar/baz", "--full"] - assert_file "script/rails", /#!foo\/bar\/baz/ + assert_file "bin/rails", /#!foo\/bar\/baz/ end def test_shebang_when_is_the_same_as_default_use_env run_generator [destination_root, "--ruby", Thor::Util.ruby_command, "--full"] - assert_file "script/rails", /#!\/usr\/bin\/env/ + assert_file "bin/rails", /#!\/usr\/bin\/env/ end def test_template_raises_an_error_with_invalid_path diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 172a42a549..7ae1b5ccfd 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -206,7 +206,7 @@ module TestHelpers def script(script) Dir.chdir(app_path) do - `#{Gem.ruby} #{app_path}/script/rails #{script}` + `#{Gem.ruby} #{app_path}/bin/rails #{script}` end end diff --git a/railties/test/script_rails_loader_test.rb b/railties/test/script_rails_loader_test.rb deleted file mode 100644 index 3ccc147749..0000000000 --- a/railties/test/script_rails_loader_test.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'abstract_unit' -require 'rails/script_rails_loader' - -class ScriptRailsLoaderTest < ActiveSupport::TestCase - - test "is in a rails application if script/rails exists" do - File.stubs(:exists?).returns(true) - assert Rails::ScriptRailsLoader.in_rails_application? - end - - test "is in a rails application if parent directory has script/rails" do - File.stubs(:exists?).with("/foo/bar/script/rails").returns(false) - File.stubs(:exists?).with("/foo/script/rails").returns(true) - assert Rails::ScriptRailsLoader.in_rails_application_subdirectory?(Pathname.new("/foo/bar")) - end - - test "is not in a rails application if at the root directory and doesn't have script/rails" do - Pathname.any_instance.stubs(:root?).returns true - assert !Rails::ScriptRailsLoader.in_rails_application? - end - -end
\ No newline at end of file |