1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

tests, railties tests should use bin/ executables when possible.

We recommend using the `bin/` executables in our docs and guides.
Let's make sure that our tests execute the same code path.
This commit is contained in:
Yves Senn 2015-06-30 11:19:01 +02:00
parent 6c3fcc58ff
commit a8f250a22c
9 changed files with 121 additions and 121 deletions

View file

@ -36,7 +36,7 @@ module ApplicationTests
test "assets are concatenated when debug is off and compile is off either if debug_assets param is provided" do
# config.assets.debug and config.assets.compile are false for production environment
ENV["RAILS_ENV"] = "production"
output = Dir.chdir(app_path){ `bundle exec rake assets:precompile --trace 2>&1` }
output = Dir.chdir(app_path){ `bin/rake assets:precompile --trace 2>&1` }
assert $?.success?, output
require "#{app_path}/config/environment"

View file

@ -18,7 +18,7 @@ module ApplicationTests
def precompile!(env = nil)
quietly do
precompile_task = "bundle exec rake assets:precompile #{env} --trace 2>&1"
precompile_task = "bin/rake assets:precompile #{env} --trace 2>&1"
output = Dir.chdir(app_path) { %x[ #{precompile_task} ] }
assert $?.success?, output
output
@ -27,7 +27,7 @@ module ApplicationTests
def clean_assets!
quietly do
assert Dir.chdir(app_path) { system('bundle exec rake assets:clobber') }
assert Dir.chdir(app_path) { system('bin/rake assets:clobber') }
end
end

View file

@ -206,7 +206,7 @@ module ApplicationTests
test "use schema cache dump" do
Dir.chdir(app_path) do
`rails generate model post title:string;
bundle exec rake db:migrate db:schema:cache:dump`
bin/rake db:migrate db:schema:cache:dump`
end
require "#{app_path}/config/environment"
ActiveRecord::Base.connection.drop_table("posts") # force drop posts table for test.
@ -216,7 +216,7 @@ module ApplicationTests
test "expire schema cache dump" do
Dir.chdir(app_path) do
`rails generate model post title:string;
bundle exec rake db:migrate db:schema:cache:dump db:rollback`
bin/rake db:migrate db:schema:cache:dump db:rollback`
end
silence_warnings {
require "#{app_path}/config/environment"

View file

@ -28,11 +28,11 @@ module ApplicationTests
def db_create_and_drop(expected_database)
Dir.chdir(app_path) do
output = `bundle exec rake db:create`
output = `bin/rake db:create`
assert_empty output
assert File.exist?(expected_database)
assert_equal expected_database, ActiveRecord::Base.connection_config[:database]
output = `bundle exec rake db:drop`
output = `bin/rake db:drop`
assert_empty output
assert !File.exist?(expected_database)
end
@ -51,9 +51,9 @@ module ApplicationTests
def db_migrate_and_status(expected_database)
Dir.chdir(app_path) do
`rails generate model book title:string;
bundle exec rake db:migrate`
output = `bundle exec rake db:migrate:status`
`bin/rails generate model book title:string;
bin/rake db:migrate`
output = `bin/rake db:migrate:status`
assert_match(%r{database:\s+\S*#{Regexp.escape(expected_database)}}, output)
assert_match(/up\s+\d{14}\s+Create books/, output)
end
@ -72,8 +72,8 @@ module ApplicationTests
def db_schema_dump
Dir.chdir(app_path) do
`rails generate model book title:string;
rake db:migrate db:schema:dump`
`bin/rails generate model book title:string;
bin/rake db:migrate db:schema:dump`
schema_dump = File.read("db/schema.rb")
assert_match(/create_table \"books\"/, schema_dump)
end
@ -90,8 +90,8 @@ module ApplicationTests
def db_fixtures_load(expected_database)
Dir.chdir(app_path) do
`rails generate model book title:string;
bundle exec rake db:migrate db:fixtures:load`
`bin/rails generate model book title:string;
bin/rake db:migrate db:fixtures:load`
assert_match expected_database, ActiveRecord::Base.connection_config[:database]
require "#{app_path}/app/models/book"
assert_equal 2, Book.count
@ -112,8 +112,8 @@ module ApplicationTests
test 'db:fixtures:load with namespaced fixture' do
require "#{app_path}/config/environment"
Dir.chdir(app_path) do
`rails generate model admin::book title:string;
bundle exec rake db:migrate db:fixtures:load`
`bin/rails generate model admin::book title:string;
bin/rake db:migrate db:fixtures:load`
require "#{app_path}/app/models/admin/book"
assert_equal 2, Admin::Book.count
end
@ -121,11 +121,11 @@ module ApplicationTests
def db_structure_dump_and_load(expected_database)
Dir.chdir(app_path) do
`rails generate model book title:string;
bundle exec rake db:migrate db:structure:dump`
`bin/rails generate model book title:string;
bin/rake db:migrate db:structure:dump`
structure_dump = File.read("db/structure.sql")
assert_match(/CREATE TABLE \"books\"/, structure_dump)
`bundle exec rake environment db:drop db:structure:load`
`bin/rake environment db:drop db:structure:load`
assert_match expected_database, ActiveRecord::Base.connection_config[:database]
require "#{app_path}/app/models/book"
#if structure is not loaded correctly, exception would be raised
@ -147,9 +147,9 @@ module ApplicationTests
test 'db:structure:dump does not dump schema information when no migrations are used' do
Dir.chdir(app_path) do
# create table without migrations
`bundle exec rails runner 'ActiveRecord::Base.connection.create_table(:posts) {|t| t.string :title }'`
`bin/rails runner 'ActiveRecord::Base.connection.create_table(:posts) {|t| t.string :title }'`
stderr_output = capture(:stderr) { `bundle exec rake db:structure:dump` }
stderr_output = capture(:stderr) { `bin/rake db:structure:dump` }
assert_empty stderr_output
structure_dump = File.read("db/structure.sql")
assert_match(/CREATE TABLE \"posts\"/, structure_dump)
@ -211,8 +211,8 @@ module ApplicationTests
def db_test_load_structure
Dir.chdir(app_path) do
`rails generate model book title:string;
bundle exec rake db:migrate db:structure:dump db:test:load_structure`
`bin/rails generate model book title:string;
bin/rake db:migrate db:structure:dump db:test:load_structure`
ActiveRecord::Base.configurations = Rails.application.config.database_configuration
ActiveRecord::Base.establish_connection :test
require "#{app_path}/app/models/book"
@ -248,7 +248,7 @@ module ApplicationTests
RUBY
Dir.chdir(app_path) do
database_path = `bundle exec rake db:setup`
database_path = `bin/rake db:setup`
assert_equal "development.sqlite3", File.basename(database_path.strip)
end
ensure

View file

@ -15,21 +15,21 @@ module ApplicationTests
test 'running migrations with given scope' do
Dir.chdir(app_path) do
`rails generate model user username:string password:string`
`bin/rails generate model user username:string password:string`
app_file "db/migrate/01_a_migration.bukkits.rb", <<-MIGRATION
class AMigration < ActiveRecord::Migration
end
MIGRATION
output = `rake db:migrate SCOPE=bukkits`
output = `bin/rake db:migrate SCOPE=bukkits`
assert_no_match(/create_table\(:users\)/, output)
assert_no_match(/CreateUsers/, output)
assert_no_match(/add_column\(:users, :email, :string\)/, output)
assert_match(/AMigration: migrated/, output)
output = `rake db:migrate SCOPE=bukkits VERSION=0`
output = `bin/rake db:migrate SCOPE=bukkits VERSION=0`
assert_no_match(/drop_table\(:users\)/, output)
assert_no_match(/CreateUsers/, output)
assert_no_match(/remove_column\(:users, :email\)/, output)
@ -40,16 +40,16 @@ module ApplicationTests
test 'model and migration generator with change syntax' do
Dir.chdir(app_path) do
`rails generate model user username:string password:string;
rails generate migration add_email_to_users email:string`
`bin/rails generate model user username:string password:string;
bin/rails generate migration add_email_to_users email:string`
output = `rake db:migrate`
output = `bin/rake db:migrate`
assert_match(/create_table\(:users\)/, output)
assert_match(/CreateUsers: migrated/, output)
assert_match(/add_column\(:users, :email, :string\)/, output)
assert_match(/AddEmailToUsers: migrated/, output)
output = `rake db:rollback STEP=2`
output = `bin/rake db:rollback STEP=2`
assert_match(/drop_table\(:users\)/, output)
assert_match(/CreateUsers: reverted/, output)
assert_match(/remove_column\(:users, :email, :string\)/, output)
@ -58,23 +58,23 @@ module ApplicationTests
end
test 'migration status when schema migrations table is not present' do
output = Dir.chdir(app_path){ `rake db:migrate:status 2>&1` }
output = Dir.chdir(app_path){ `bin/rake db:migrate:status 2>&1` }
assert_equal "Schema migrations table does not exist yet.\n", output
end
test 'test migration status' do
Dir.chdir(app_path) do
`rails generate model user username:string password:string;
rails generate migration add_email_to_users email:string;
rake db:migrate`
`bin/rails generate model user username:string password:string;
bin/rails generate migration add_email_to_users email:string;
bin/rake db:migrate`
output = `rake db:migrate:status`
output = `bin/rake db:migrate:status`
assert_match(/up\s+\d{14}\s+Create users/, output)
assert_match(/up\s+\d{14}\s+Add email to users/, output)
`rake db:rollback STEP=1`
output = `rake db:migrate:status`
`bin/rake db:rollback STEP=1`
output = `bin/rake db:migrate:status`
assert_match(/up\s+\d{14}\s+Create users/, output)
assert_match(/down\s+\d{14}\s+Add email to users/, output)
@ -85,17 +85,17 @@ module ApplicationTests
add_to_config('config.active_record.timestamped_migrations = false')
Dir.chdir(app_path) do
`rails generate model user username:string password:string;
rails generate migration add_email_to_users email:string;
rake db:migrate`
`bin/rails generate model user username:string password:string;
bin/rails generate migration add_email_to_users email:string;
bin/rake db:migrate`
output = `rake db:migrate:status`
output = `bin/rake db:migrate:status`
assert_match(/up\s+\d{3,}\s+Create users/, output)
assert_match(/up\s+\d{3,}\s+Add email to users/, output)
`rake db:rollback STEP=1`
output = `rake db:migrate:status`
`bin/rake db:rollback STEP=1`
output = `bin/rake db:migrate:status`
assert_match(/up\s+\d{3,}\s+Create users/, output)
assert_match(/down\s+\d{3,}\s+Add email to users/, output)
@ -104,23 +104,23 @@ module ApplicationTests
test 'test migration status after rollback and redo' do
Dir.chdir(app_path) do
`rails generate model user username:string password:string;
rails generate migration add_email_to_users email:string;
rake db:migrate`
`bin/rails generate model user username:string password:string;
bin/rails generate migration add_email_to_users email:string;
bin/rake db:migrate`
output = `rake db:migrate:status`
output = `bin/rake db:migrate:status`
assert_match(/up\s+\d{14}\s+Create users/, output)
assert_match(/up\s+\d{14}\s+Add email to users/, output)
`rake db:rollback STEP=2`
output = `rake db:migrate:status`
`bin/rake db:rollback STEP=2`
output = `bin/rake db:migrate:status`
assert_match(/down\s+\d{14}\s+Create users/, output)
assert_match(/down\s+\d{14}\s+Add email to users/, output)
`rake db:migrate:redo`
output = `rake db:migrate:status`
`bin/rake db:migrate:redo`
output = `bin/rake db:migrate:status`
assert_match(/up\s+\d{14}\s+Create users/, output)
assert_match(/up\s+\d{14}\s+Add email to users/, output)
@ -131,23 +131,23 @@ module ApplicationTests
add_to_config('config.active_record.timestamped_migrations = false')
Dir.chdir(app_path) do
`rails generate model user username:string password:string;
rails generate migration add_email_to_users email:string;
rake db:migrate`
`bin/rails generate model user username:string password:string;
bin/rails generate migration add_email_to_users email:string;
bin/rake db:migrate`
output = `rake db:migrate:status`
output = `bin/rake db:migrate:status`
assert_match(/up\s+\d{3,}\s+Create users/, output)
assert_match(/up\s+\d{3,}\s+Add email to users/, output)
`rake db:rollback STEP=2`
output = `rake db:migrate:status`
`bin/rake db:rollback STEP=2`
output = `bin/rake db:migrate:status`
assert_match(/down\s+\d{3,}\s+Create users/, output)
assert_match(/down\s+\d{3,}\s+Add email to users/, output)
`rake db:migrate:redo`
output = `rake db:migrate:status`
`bin/rake db:migrate:redo`
output = `bin/rake db:migrate:status`
assert_match(/up\s+\d{3,}\s+Create users/, output)
assert_match(/up\s+\d{3,}\s+Add email to users/, output)
@ -158,8 +158,8 @@ module ApplicationTests
add_to_config('config.active_record.dump_schema_after_migration = false')
Dir.chdir(app_path) do
`rails generate model book title:string;
bundle exec rake db:migrate`
`bin/rails generate model book title:string;
bin/rake db:migrate`
assert !File.exist?("db/schema.rb")
end
@ -167,8 +167,8 @@ module ApplicationTests
add_to_config('config.active_record.dump_schema_after_migration = true')
Dir.chdir(app_path) do
`rails generate model author name:string;
bundle exec rake db:migrate`
`bin/rails generate model author name:string;
bin/rake db:migrate`
structure_dump = File.read("db/schema.rb")
assert_match(/create_table "authors"/, structure_dump)
@ -177,8 +177,8 @@ module ApplicationTests
test 'default schema generation after migration' do
Dir.chdir(app_path) do
`rails generate model book title:string;
bundle exec rake db:migrate`
`bin/rails generate model book title:string;
bin/rake db:migrate`
structure_dump = File.read("db/schema.rb")
assert_match(/create_table "books"/, structure_dump)
@ -187,12 +187,12 @@ module ApplicationTests
test 'test migration status migrated file is deleted' do
Dir.chdir(app_path) do
`rails generate model user username:string password:string;
rails generate migration add_email_to_users email:string;
rake db:migrate
`bin/rails generate model user username:string password:string;
bin/rails generate migration add_email_to_users email:string;
bin/rake db:migrate
rm db/migrate/*email*.rb`
output = `rake db:migrate:status`
output = `bin/rake db:migrate:status`
File.write('test.txt', output)
assert_match(/up\s+\d{14}\s+Create users/, output)

View file

@ -74,7 +74,7 @@ module ApplicationTests
app_file "some_other_dir/blah.rb", "# TODO: note in some_other directory"
run_rake_notes "SOURCE_ANNOTATION_DIRECTORIES='some_other_dir' bundle exec rake notes" do |output, lines|
run_rake_notes "SOURCE_ANNOTATION_DIRECTORIES='some_other_dir' bin/rake notes" do |output, lines|
assert_match(/note in app directory/, output)
assert_match(/note in config directory/, output)
assert_match(/note in db directory/, output)
@ -102,7 +102,7 @@ module ApplicationTests
end
EOS
run_rake_notes "bundle exec rake notes_custom" do |output, lines|
run_rake_notes "bin/rake notes_custom" do |output, lines|
assert_match(/\[FIXME\] note in lib directory/, output)
assert_match(/\[TODO\] note in test directory/, output)
assert_no_match(/OPTIMIZE/, output)
@ -127,7 +127,7 @@ module ApplicationTests
private
def run_rake_notes(command = 'bundle exec rake notes')
def run_rake_notes(command = 'bin/rake notes')
boot_rails
load_tasks

View file

@ -36,7 +36,7 @@ module ApplicationTests
Rails.application.initialize!
RUBY
assert_match("SuperMiddleware", Dir.chdir(app_path){ `rake middleware` })
assert_match("SuperMiddleware", Dir.chdir(app_path){ `bin/rake middleware` })
end
def test_initializers_are_executed_in_rake_tasks
@ -51,7 +51,7 @@ module ApplicationTests
end
RUBY
output = Dir.chdir(app_path){ `rake do_nothing` }
output = Dir.chdir(app_path){ `bin/rake do_nothing` }
assert_match "Doing something...", output
end
@ -72,7 +72,7 @@ module ApplicationTests
end
RUBY
output = Dir.chdir(app_path) { `rake do_nothing` }
output = Dir.chdir(app_path) { `bin/rake do_nothing` }
assert_match 'Hello world', output
end
@ -93,14 +93,14 @@ module ApplicationTests
RUBY
Dir.chdir(app_path) do
assert system('rake do_nothing RAILS_ENV=production'),
assert system('bin/rake do_nothing RAILS_ENV=production'),
'should not be pre-required for rake even eager_load=true'
end
end
def test_code_statistics_sanity
assert_match "Code LOC: 7 Test LOC: 0 Code to Test Ratio: 1:0.0",
Dir.chdir(app_path){ `rake stats` }
Dir.chdir(app_path){ `bin/rake stats` }
end
def test_rake_routes_calls_the_route_inspector
@ -110,7 +110,7 @@ module ApplicationTests
end
RUBY
output = Dir.chdir(app_path){ `rake routes` }
output = Dir.chdir(app_path){ `bin/rake routes` }
assert_equal "Prefix Verb URI Pattern Controller#Action\n cart GET /cart(.:format) cart#show\n", output
end
@ -123,7 +123,7 @@ module ApplicationTests
RUBY
ENV['CONTROLLER'] = 'cart'
output = Dir.chdir(app_path){ `rake routes` }
output = Dir.chdir(app_path){ `bin/rake routes` }
assert_equal "Prefix Verb URI Pattern Controller#Action\n cart GET /cart(.:format) cart#show\n", output
end
@ -133,7 +133,7 @@ module ApplicationTests
end
RUBY
assert_equal <<-MESSAGE.strip_heredoc, Dir.chdir(app_path){ `rake routes` }
assert_equal <<-MESSAGE.strip_heredoc, Dir.chdir(app_path){ `bin/rake routes` }
You don't have any routes defined!
Please add some routes in config/routes.rb.
@ -151,21 +151,21 @@ module ApplicationTests
end
RUBY
output = Dir.chdir(app_path){ `rake log_something RAILS_ENV=production && cat log/production.log` }
output = Dir.chdir(app_path){ `bin/rake log_something RAILS_ENV=production && cat log/production.log` }
assert_match "Sample log message", output
end
def test_loading_specific_fixtures
Dir.chdir(app_path) do
`rails generate model user username:string password:string;
rails generate model product name:string;
rake db:migrate`
`bin/rails generate model user username:string password:string;
bin/rails generate model product name:string;
bin/rake db:migrate`
end
require "#{rails_root}/config/environment"
# loading a specific fixture
errormsg = Dir.chdir(app_path) { `rake db:fixtures:load FIXTURES=products` }
errormsg = Dir.chdir(app_path) { `bin/rake db:fixtures:load FIXTURES=products` }
assert $?.success?, errormsg
assert_equal 2, ::AppTemplate::Application::Product.count
@ -174,20 +174,20 @@ module ApplicationTests
def test_loading_only_yml_fixtures
Dir.chdir(app_path) do
`rake db:migrate`
`bin/rake db:migrate`
end
app_file "test/fixtures/products.csv", ""
require "#{rails_root}/config/environment"
errormsg = Dir.chdir(app_path) { `rake db:fixtures:load` }
errormsg = Dir.chdir(app_path) { `bin/rake db:fixtures:load` }
assert $?.success?, errormsg
end
def test_scaffold_tests_pass_by_default
output = Dir.chdir(app_path) do
`rails generate scaffold user username:string password:string;
bundle exec rake db:migrate test`
`bin/rails generate scaffold user username:string password:string;
bin/rake db:migrate test`
end
assert_match(/7 runs, 12 assertions, 0 failures, 0 errors/, output)
@ -205,8 +205,8 @@ module ApplicationTests
RUBY
output = Dir.chdir(app_path) do
`rails generate scaffold user username:string password:string;
bundle exec rake db:migrate test`
`bin/rails generate scaffold user username:string password:string;
bin/rake db:migrate test`
end
assert_match(/5 runs, 7 assertions, 0 failures, 0 errors/, output)
@ -218,8 +218,8 @@ module ApplicationTests
"Rails.application.config.active_record.belongs_to_required_by_default = false"
output = Dir.chdir(app_path) do
`rails generate scaffold LineItems product:references cart:belongs_to;
bundle exec rake db:migrate test`
`bin/rails generate scaffold LineItems product:references cart:belongs_to;
bin/rake db:migrate test`
end
assert_match(/7 runs, 12 assertions, 0 failures, 0 errors/, output)
@ -229,9 +229,9 @@ module ApplicationTests
def test_db_test_clone_when_using_sql_format
add_to_config "config.active_record.schema_format = :sql"
output = Dir.chdir(app_path) do
`rails generate scaffold user username:string;
bundle exec rake db:migrate;
bundle exec rake db:test:clone 2>&1 --trace`
`bin/rails generate scaffold user username:string;
bin/rake db:migrate;
bin/rake db:test:clone 2>&1 --trace`
end
assert_match(/Execute db:test:clone_structure/, output)
end
@ -239,9 +239,9 @@ module ApplicationTests
def test_db_test_prepare_when_using_sql_format
add_to_config "config.active_record.schema_format = :sql"
output = Dir.chdir(app_path) do
`rails generate scaffold user username:string;
bundle exec rake db:migrate;
bundle exec rake db:test:prepare 2>&1 --trace`
`bin/rails generate scaffold user username:string;
bin/rake db:migrate;
bin/rake db:test:prepare 2>&1 --trace`
end
assert_match(/Execute db:test:load_structure/, output)
end
@ -249,7 +249,7 @@ module ApplicationTests
def test_rake_dump_structure_should_respect_db_structure_env_variable
Dir.chdir(app_path) do
# ensure we have a schema_migrations table to dump
`bundle exec rake db:migrate db:structure:dump SCHEMA=db/my_structure.sql`
`bin/rake db:migrate db:structure:dump SCHEMA=db/my_structure.sql`
end
assert File.exist?(File.join(app_path, 'db', 'my_structure.sql'))
end
@ -258,8 +258,8 @@ module ApplicationTests
add_to_config "config.active_record.schema_format = :sql"
output = Dir.chdir(app_path) do
`rails g model post title:string;
bundle exec rake db:migrate:redo 2>&1 --trace;`
`bin/rails g model post title:string;
bin/rake db:migrate:redo 2>&1 --trace;`
end
# expect only Invoke db:structure:dump (first_time)
@ -268,23 +268,23 @@ module ApplicationTests
def test_rake_dump_schema_cache
Dir.chdir(app_path) do
`rails generate model post title:string;
rails generate model product name:string;
bundle exec rake db:migrate db:schema:cache:dump`
`bin/rails generate model post title:string;
bin/rails generate model product name:string;
bin/rake db:migrate db:schema:cache:dump`
end
assert File.exist?(File.join(app_path, 'db', 'schema_cache.dump'))
end
def test_rake_clear_schema_cache
Dir.chdir(app_path) do
`bundle exec rake db:schema:cache:dump db:schema:cache:clear`
`bin/rake db:schema:cache:dump db:schema:cache:clear`
end
assert !File.exist?(File.join(app_path, 'db', 'schema_cache.dump'))
end
def test_copy_templates
Dir.chdir(app_path) do
`bundle exec rake rails:templates:copy`
`bin/rake rails:templates:copy`
%w(controller mailer scaffold).each do |dir|
assert File.exist?(File.join(app_path, 'lib', 'templates', 'erb', dir))
end
@ -299,7 +299,7 @@ module ApplicationTests
app_file "template.rb", ""
output = Dir.chdir(app_path) do
`bundle exec rake rails:template LOCATION=template.rb`
`bin/rake rails:template LOCATION=template.rb`
end
assert_match(/Hello, World!/, output)
@ -307,7 +307,7 @@ module ApplicationTests
def test_tmp_clear_should_work_if_folder_missing
FileUtils.remove_dir("#{app_path}/tmp")
errormsg = Dir.chdir(app_path) { `bundle exec rake tmp:clear` }
errormsg = Dir.chdir(app_path) { `bin/rake tmp:clear` }
assert_predicate $?, :success?
assert_empty errormsg
end

View file

@ -25,15 +25,15 @@ module ApplicationTests
end
def test_should_include_runner_in_shebang_line_in_help_without_option
assert_match "/rails runner", Dir.chdir(app_path) { `bundle exec rails runner` }
assert_match "/rails runner", Dir.chdir(app_path) { `bin/rails runner` }
end
def test_should_include_runner_in_shebang_line_in_help
assert_match "/rails runner", Dir.chdir(app_path) { `bundle exec rails runner --help` }
assert_match "/rails runner", Dir.chdir(app_path) { `bin/rails runner --help` }
end
def test_should_run_ruby_statement
assert_match "42", Dir.chdir(app_path) { `bundle exec rails runner "puts User.count"` }
assert_match "42", Dir.chdir(app_path) { `bin/rails runner "puts User.count"` }
end
def test_should_run_file
@ -41,7 +41,7 @@ module ApplicationTests
puts User.count
SCRIPT
assert_match "42", Dir.chdir(app_path) { `bundle exec rails runner "bin/count_users.rb"` }
assert_match "42", Dir.chdir(app_path) { `bin/rails runner "bin/count_users.rb"` }
end
def test_should_set_dollar_0_to_file
@ -49,7 +49,7 @@ module ApplicationTests
puts $0
SCRIPT
assert_match "bin/dollar0.rb", Dir.chdir(app_path) { `bundle exec rails runner "bin/dollar0.rb"` }
assert_match "bin/dollar0.rb", Dir.chdir(app_path) { `bin/rails runner "bin/dollar0.rb"` }
end
def test_should_set_dollar_program_name_to_file
@ -57,7 +57,7 @@ module ApplicationTests
puts $PROGRAM_NAME
SCRIPT
assert_match "bin/program_name.rb", Dir.chdir(app_path) { `bundle exec rails runner "bin/program_name.rb"` }
assert_match "bin/program_name.rb", Dir.chdir(app_path) { `bin/rails runner "bin/program_name.rb"` }
end
def test_with_hook
@ -67,22 +67,22 @@ module ApplicationTests
end
RUBY
assert_match "true", Dir.chdir(app_path) { `bundle exec rails runner "puts Rails.application.config.ran"` }
assert_match "true", Dir.chdir(app_path) { `bin/rails runner "puts Rails.application.config.ran"` }
end
def test_default_environment
assert_match "development", Dir.chdir(app_path) { `bundle exec rails runner "puts Rails.env"` }
assert_match "development", Dir.chdir(app_path) { `bin/rails runner "puts Rails.env"` }
end
def test_environment_with_rails_env
with_rails_env "production" do
assert_match "production", Dir.chdir(app_path) { `bundle exec rails runner "puts Rails.env"` }
assert_match "production", Dir.chdir(app_path) { `bin/rails runner "puts Rails.env"` }
end
end
def test_environment_with_rack_env
with_rack_env "production" do
assert_match "production", Dir.chdir(app_path) { `bundle exec rails runner "puts Rails.env"` }
assert_match "production", Dir.chdir(app_path) { `bin/rails runner "puts Rails.env"` }
end
end
end

View file

@ -423,7 +423,7 @@ module ApplicationTests
end
def run_migration
Dir.chdir(app_path) { `bundle exec rake db:migrate` }
Dir.chdir(app_path) { `bin/rake db:migrate` }
end
end
end