mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Invoke rails command inside the railties' test app with TestHelpers::Generation#rails
See #30520
This commit is contained in:
parent
ff67743fb2
commit
0eb2d6079a
3 changed files with 12 additions and 16 deletions
|
@ -300,7 +300,7 @@ class LoadingTest < ActiveSupport::TestCase
|
|||
end
|
||||
MIGRATION
|
||||
|
||||
Dir.chdir(app_path) { `rake db:migrate` }
|
||||
rails("db:migrate")
|
||||
require "#{rails_root}/config/environment"
|
||||
|
||||
get "/title"
|
||||
|
@ -314,7 +314,7 @@ class LoadingTest < ActiveSupport::TestCase
|
|||
end
|
||||
MIGRATION
|
||||
|
||||
Dir.chdir(app_path) { `rake db:migrate` }
|
||||
rails("db:migrate")
|
||||
|
||||
get "/body"
|
||||
assert_equal "BODY", last_response.body
|
||||
|
|
|
@ -101,6 +101,7 @@ module ApplicationTests
|
|||
add_to_config <<-RUBY
|
||||
rake_tasks do
|
||||
task do_nothing: :environment do
|
||||
puts 'There is nothing'
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
|
@ -113,10 +114,8 @@ module ApplicationTests
|
|||
raise 'should not be pre-required for rake even eager_load=true'
|
||||
RUBY
|
||||
|
||||
Dir.chdir(app_path) do
|
||||
assert system("bin/rails do_nothing RAILS_ENV=production"),
|
||||
"should not be pre-required for rake even eager_load=true"
|
||||
end
|
||||
output = rails("do_nothing", "RAILS_ENV=production")
|
||||
assert_match "There is nothing", output
|
||||
end
|
||||
|
||||
def test_code_statistics_sanity
|
||||
|
@ -294,9 +293,8 @@ module ApplicationTests
|
|||
|
||||
def test_scaffold_tests_pass_by_default
|
||||
rails "generate", "scaffold", "user", "username:string", "password:string"
|
||||
output = Dir.chdir(app_path) do
|
||||
`RAILS_ENV=test bin/rails db:migrate test`
|
||||
end
|
||||
with_rails_env("test") { rails("db:migrate") }
|
||||
output = rails("test")
|
||||
|
||||
assert_match(/7 runs, 9 assertions, 0 failures, 0 errors/, output)
|
||||
assert_no_match(/Errors running/, output)
|
||||
|
@ -313,9 +311,8 @@ module ApplicationTests
|
|||
RUBY
|
||||
|
||||
rails "generate", "scaffold", "user", "username:string", "password:string"
|
||||
output = Dir.chdir(app_path) do
|
||||
`RAILS_ENV=test bin/rails db:migrate test`
|
||||
end
|
||||
with_rails_env("test") { rails("db:migrate") }
|
||||
output = rails("test")
|
||||
|
||||
assert_match(/5 runs, 7 assertions, 0 failures, 0 errors/, output)
|
||||
assert_no_match(/Errors running/, output)
|
||||
|
@ -325,9 +322,8 @@ module ApplicationTests
|
|||
rails "generate", "model", "Product"
|
||||
rails "generate", "model", "Cart"
|
||||
rails "generate", "scaffold", "LineItems", "product:references", "cart:belongs_to"
|
||||
output = Dir.chdir(app_path) do
|
||||
`RAILS_ENV=test bin/rails db:migrate test`
|
||||
end
|
||||
with_rails_env("test") { rails("db:migrate") }
|
||||
output = rails("test")
|
||||
|
||||
assert_match(/7 runs, 9 assertions, 0 failures, 0 errors/, output)
|
||||
assert_no_match(/Errors running/, output)
|
||||
|
|
|
@ -42,7 +42,7 @@ module ApplicationTests
|
|||
pid = Process.spawn("#{app_path}/bin/rails server -P tmp/dummy.pid", in: slave, out: slave, err: slave)
|
||||
assert_output("Listening", master)
|
||||
|
||||
Dir.chdir(app_path) { system("bin/rails restart") }
|
||||
rails("restart")
|
||||
|
||||
assert_output("Restarting", master)
|
||||
assert_output("Inherited", master)
|
||||
|
|
Loading…
Reference in a new issue