mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
8ac8396259
Addressing warnings are important but it should be out of this test scope. https://travis-ci.org/rails/rails/jobs/454145524#L4122-L4131 ``` .F Failure: ApplicationTests::BinSetupTest#test_bin_setup_output [test/application/bin_setup_test.rb:49]: --- expected +++ actual @@ -1,4 +1,5 @@ "== Installing dependencies == +warning: Passing permitted_classes with the 2nd argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, permitted_classes: ...) instead. The Gemfile's dependencies are satisfied == Preparing database == rails test test/application/bin_setup_test.rb:38 ```
66 lines
1.9 KiB
Ruby
66 lines
1.9 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "isolation/abstract_unit"
|
|
|
|
module ApplicationTests
|
|
class BinSetupTest < ActiveSupport::TestCase
|
|
include ActiveSupport::Testing::Isolation
|
|
|
|
def setup
|
|
build_app
|
|
end
|
|
|
|
def teardown
|
|
teardown_app
|
|
end
|
|
|
|
def test_bin_setup
|
|
Dir.chdir(app_path) do
|
|
app_file "db/schema.rb", <<-RUBY
|
|
ActiveRecord::Schema.define(version: 20140423102712) do
|
|
create_table(:articles) {}
|
|
end
|
|
RUBY
|
|
|
|
list_tables = lambda { rails("runner", "p ActiveRecord::Base.connection.tables").strip }
|
|
File.write("log/test.log", "zomg!")
|
|
|
|
assert_equal "[]", list_tables.call
|
|
assert_equal 5, File.size("log/test.log")
|
|
assert_not File.exist?("tmp/restart.txt")
|
|
`bin/setup 2>&1`
|
|
assert_equal 0, File.size("log/test.log")
|
|
assert_equal '["articles", "schema_migrations", "ar_internal_metadata"]', list_tables.call
|
|
assert File.exist?("tmp/restart.txt")
|
|
end
|
|
end
|
|
|
|
def test_bin_setup_output
|
|
Dir.chdir(app_path) do
|
|
app_file "db/schema.rb", ""
|
|
|
|
output = `bin/setup 2>&1`
|
|
|
|
# Ignore line that's only output by Bundler < 1.14
|
|
output.sub!(/^Resolving dependencies\.\.\.\n/, "")
|
|
# Suppress Bundler platform warnings from output
|
|
output.gsub!(/^The dependency .* will be unused .*\.\n/, "")
|
|
# Ignore warnings such as `Psych.safe_load is deprecated`
|
|
output.gsub!(/^warning:\s.*\n/, "")
|
|
|
|
assert_equal(<<~OUTPUT, output)
|
|
== Installing dependencies ==
|
|
The Gemfile's dependencies are satisfied
|
|
|
|
== Preparing database ==
|
|
Created database 'db/development.sqlite3'
|
|
Created database 'db/test.sqlite3'
|
|
|
|
== Removing old logs and tempfiles ==
|
|
|
|
== Restarting application server ==
|
|
OUTPUT
|
|
end
|
|
end
|
|
end
|
|
end
|