diff options
author | Yves Senn <yves.senn@gmail.com> | 2015-05-06 10:32:38 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2015-05-06 10:32:38 +0200 |
commit | 2d1a7b9c76a2cde7531d7d3c544c630e916ed481 (patch) | |
tree | a2b8782daebfa231197c801371a27e311b8f1731 /railties | |
parent | a64d47ff04574e701a656efcb5283179159c7908 (diff) | |
download | rails-2d1a7b9c76a2cde7531d7d3c544c630e916ed481.tar.gz rails-2d1a7b9c76a2cde7531d7d3c544c630e916ed481.tar.bz2 rails-2d1a7b9c76a2cde7531d7d3c544c630e916ed481.zip |
add test coverage for `bin/setup`.
Make sure this script keeps working and has consistent output.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/test/application/bin_setup_test.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/railties/test/application/bin_setup_test.rb b/railties/test/application/bin_setup_test.rb new file mode 100644 index 0000000000..1bdced02e9 --- /dev/null +++ b/railties/test/application/bin_setup_test.rb @@ -0,0 +1,54 @@ +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 { `bin/rails runner 'p ActiveRecord::Base.connection.tables'`.strip } + File.write("log/my.log", "zomg!") + + assert_equal '[]', list_tables.call + assert_equal 5, File.size("log/my.log") + assert_not File.exist?("tmp/restart.txt") + `bin/setup 2>&1` + assert_equal 0, File.size("log/my.log") + assert_equal '["articles", "schema_migrations"]', 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` + assert_equal(<<-OUTPUT, output) +== Installing dependencies == +The Gemfile's dependencies are satisfied + +== Preparing database == + +== Removing old logs and tempfiles == + +== Restarting application server == + OUTPUT + end + end + end +end |