aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application/rake
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-08-06 19:16:09 +0200
committerXavier Noria <fxn@hashref.com>2016-08-06 19:16:09 +0200
commit783763bde97bea3d0c200038453008a8cfff1e88 (patch)
tree898d547f9d4c4e767362e6c6dc722b98fec4c07b /railties/test/application/rake
parent69ab3eb57e8387b0dd9d672b5e8d9185395baa03 (diff)
downloadrails-783763bde97bea3d0c200038453008a8cfff1e88.tar.gz
rails-783763bde97bea3d0c200038453008a8cfff1e88.tar.bz2
rails-783763bde97bea3d0c200038453008a8cfff1e88.zip
applies new string literal convention in railties/test
The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
Diffstat (limited to 'railties/test/application/rake')
-rw-r--r--railties/test/application/rake/dbs_test.rb64
-rw-r--r--railties/test/application/rake/dev_test.rb12
-rw-r--r--railties/test/application/rake/framework_test.rb10
-rw-r--r--railties/test/application/rake/migrations_test.rb32
-rw-r--r--railties/test/application/rake/notes_test.rb28
-rw-r--r--railties/test/application/rake/restart_test.rb10
6 files changed, 78 insertions, 78 deletions
diff --git a/railties/test/application/rake/dbs_test.rb b/railties/test/application/rake/dbs_test.rb
index f9bf670c5a..51db634b75 100644
--- a/railties/test/application/rake/dbs_test.rb
+++ b/railties/test/application/rake/dbs_test.rb
@@ -20,7 +20,7 @@ module ApplicationTests
end
def set_database_url
- ENV['DATABASE_URL'] = "sqlite3:#{database_url_db_name}"
+ ENV["DATABASE_URL"] = "sqlite3:#{database_url_db_name}"
# ensure it's using the DATABASE_URL
FileUtils.rm_rf("#{app_path}/config/database.yml")
end
@@ -37,12 +37,12 @@ module ApplicationTests
end
end
- test 'db:create and db:drop without database url' do
+ test "db:create and db:drop without database url" do
require "#{app_path}/config/environment"
- db_create_and_drop ActiveRecord::Base.configurations[Rails.env]['database']
+ db_create_and_drop ActiveRecord::Base.configurations[Rails.env]["database"]
end
- test 'db:create and db:drop with database url' do
+ test "db:create and db:drop with database url" do
require "#{app_path}/config/environment"
set_database_url
db_create_and_drop database_url_db_name
@@ -57,7 +57,7 @@ module ApplicationTests
end
end
- test 'db:create failure because database exists' do
+ test "db:create failure because database exists" do
with_database_existing do
output = `bin/rails db:create 2>&1`
assert_match(/already exists/, output)
@@ -74,7 +74,7 @@ module ApplicationTests
end
end
- test 'db:create failure because bad permissions' do
+ test "db:create failure because bad permissions" do
with_bad_permissions do
output = `bin/rails db:create 2>&1`
assert_match(/Couldn't create database/, output)
@@ -82,7 +82,7 @@ module ApplicationTests
end
end
- test 'db:drop failure because database does not exist' do
+ test "db:drop failure because database does not exist" do
Dir.chdir(app_path) do
output = `bin/rails db:drop:_unsafe --trace 2>&1`
assert_match(/does not exist/, output)
@@ -90,7 +90,7 @@ module ApplicationTests
end
end
- test 'db:drop failure because bad permissions' do
+ test "db:drop failure because bad permissions" do
with_database_existing do
with_bad_permissions do
output = `bin/rails db:drop 2>&1`
@@ -110,12 +110,12 @@ module ApplicationTests
end
end
- test 'db:migrate and db:migrate:status without database_url' do
+ test "db:migrate and db:migrate:status without database_url" do
require "#{app_path}/config/environment"
- db_migrate_and_status ActiveRecord::Base.configurations[Rails.env]['database']
+ db_migrate_and_status ActiveRecord::Base.configurations[Rails.env]["database"]
end
- test 'db:migrate and db:migrate:status with database_url' do
+ test "db:migrate and db:migrate:status with database_url" do
require "#{app_path}/config/environment"
set_database_url
db_migrate_and_status database_url_db_name
@@ -130,11 +130,11 @@ module ApplicationTests
end
end
- test 'db:schema:dump without database_url' do
+ test "db:schema:dump without database_url" do
db_schema_dump
end
- test 'db:schema:dump with database_url' do
+ test "db:schema:dump with database_url" do
set_database_url
db_schema_dump
end
@@ -149,18 +149,18 @@ module ApplicationTests
end
end
- test 'db:fixtures:load without database_url' do
+ test "db:fixtures:load without database_url" do
require "#{app_path}/config/environment"
- db_fixtures_load ActiveRecord::Base.configurations[Rails.env]['database']
+ db_fixtures_load ActiveRecord::Base.configurations[Rails.env]["database"]
end
- test 'db:fixtures:load with database_url' do
+ test "db:fixtures:load with database_url" do
require "#{app_path}/config/environment"
set_database_url
db_fixtures_load database_url_db_name
end
- test 'db:fixtures:load with namespaced fixture' do
+ test "db:fixtures:load with namespaced fixture" do
require "#{app_path}/config/environment"
Dir.chdir(app_path) do
`bin/rails generate model admin::book title:string;
@@ -184,18 +184,18 @@ module ApplicationTests
end
end
- test 'db:structure:dump and db:structure:load without database_url' do
+ test "db:structure:dump and db:structure:load without database_url" do
require "#{app_path}/config/environment"
- db_structure_dump_and_load ActiveRecord::Base.configurations[Rails.env]['database']
+ db_structure_dump_and_load ActiveRecord::Base.configurations[Rails.env]["database"]
end
- test 'db:structure:dump and db:structure:load with database_url' do
+ test "db:structure:dump and db:structure:load with database_url" do
require "#{app_path}/config/environment"
set_database_url
db_structure_dump_and_load database_url_db_name
end
- test 'db:structure:dump does not dump schema information when no migrations are used' do
+ test "db:structure:dump does not dump schema information when no migrations are used" do
Dir.chdir(app_path) do
# create table without migrations
`bin/rails runner 'ActiveRecord::Base.connection.create_table(:posts) {|t| t.string :title }'`
@@ -207,11 +207,11 @@ module ApplicationTests
end
end
- test 'db:schema:load and db:structure:load do not purge the existing database' do
+ test "db:schema:load and db:structure:load do not purge the existing database" do
Dir.chdir(app_path) do
`bin/rails runner 'ActiveRecord::Base.connection.create_table(:posts) {|t| t.string :title }'`
- app_file 'db/schema.rb', <<-RUBY
+ app_file "db/schema.rb", <<-RUBY
ActiveRecord::Schema.define(version: 20140423102712) do
create_table(:comments) {}
end
@@ -223,7 +223,7 @@ module ApplicationTests
`bin/rails db:schema:load`
assert_equal '["posts", "comments", "schema_migrations", "ar_internal_metadata"]', list_tables[]
- app_file 'db/structure.sql', <<-SQL
+ app_file "db/structure.sql", <<-SQL
CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255));
SQL
@@ -234,15 +234,15 @@ module ApplicationTests
test "db:schema:load with inflections" do
Dir.chdir(app_path) do
- app_file 'config/initializers/inflection.rb', <<-RUBY
+ app_file "config/initializers/inflection.rb", <<-RUBY
ActiveSupport::Inflector.inflections do |inflect|
inflect.irregular 'goose', 'geese'
end
RUBY
- app_file 'config/initializers/primary_key_table_name.rb', <<-RUBY
+ app_file "config/initializers/primary_key_table_name.rb", <<-RUBY
ActiveRecord::Base.primary_key_prefix_type = :table_name
RUBY
- app_file 'db/schema.rb', <<-RUBY
+ app_file "db/schema.rb", <<-RUBY
ActiveRecord::Schema.define(version: 20140423102712) do
create_table("goose".pluralize) do |t|
t.string :name
@@ -269,24 +269,24 @@ module ApplicationTests
require "#{app_path}/app/models/book"
#if structure is not loaded correctly, exception would be raised
assert_equal 0, Book.count
- assert_match ActiveRecord::Base.configurations['test']['database'],
+ assert_match ActiveRecord::Base.configurations["test"]["database"],
ActiveRecord::Base.connection_config[:database]
end
end
- test 'db:test:load_structure without database_url' do
+ test "db:test:load_structure without database_url" do
require "#{app_path}/config/environment"
db_test_load_structure
end
- test 'db:setup loads schema and seeds database' do
+ test "db:setup loads schema and seeds database" do
begin
@old_rails_env = ENV["RAILS_ENV"]
@old_rack_env = ENV["RACK_ENV"]
ENV.delete "RAILS_ENV"
ENV.delete "RACK_ENV"
- app_file 'db/schema.rb', <<-RUBY
+ app_file "db/schema.rb", <<-RUBY
ActiveRecord::Schema.define(version: "1") do
create_table :users do |t|
t.string :name
@@ -294,7 +294,7 @@ module ApplicationTests
end
RUBY
- app_file 'db/seeds.rb', <<-RUBY
+ app_file "db/seeds.rb", <<-RUBY
puts ActiveRecord::Base.connection_config[:database]
RUBY
diff --git a/railties/test/application/rake/dev_test.rb b/railties/test/application/rake/dev_test.rb
index 2330ad3535..4f992d9c8d 100644
--- a/railties/test/application/rake/dev_test.rb
+++ b/railties/test/application/rake/dev_test.rb
@@ -1,4 +1,4 @@
-require 'isolation/abstract_unit'
+require "isolation/abstract_unit"
module ApplicationTests
module RakeTests
@@ -13,24 +13,24 @@ module ApplicationTests
teardown_app
end
- test 'dev:cache creates file and outputs message' do
+ test "dev:cache creates file and outputs message" do
Dir.chdir(app_path) do
output = `rails dev:cache`
- assert File.exist?('tmp/caching-dev.txt')
+ assert File.exist?("tmp/caching-dev.txt")
assert_match(/Development mode is now being cached/, output)
end
end
- test 'dev:cache deletes file and outputs message' do
+ test "dev:cache deletes file and outputs message" do
Dir.chdir(app_path) do
`rails dev:cache` # Create caching file.
output = `rails dev:cache` # Delete caching file.
- assert_not File.exist?('tmp/caching-dev.txt')
+ assert_not File.exist?("tmp/caching-dev.txt")
assert_match(/Development mode is no longer being cached/, output)
end
end
- test 'dev:cache removes server.pid also' do
+ test "dev:cache removes server.pid also" do
Dir.chdir(app_path) do
FileUtils.mkdir_p("tmp/pids")
FileUtils.touch("tmp/pids/server.pid")
diff --git a/railties/test/application/rake/framework_test.rb b/railties/test/application/rake/framework_test.rb
index 04e54b2c70..7ac37b7700 100644
--- a/railties/test/application/rake/framework_test.rb
+++ b/railties/test/application/rake/framework_test.rb
@@ -16,14 +16,14 @@ module ApplicationTests
end
def load_tasks
- require 'rake'
- require 'rdoc/task'
- require 'rake/testtask'
+ require "rake"
+ require "rdoc/task"
+ require "rake/testtask"
Rails.application.load_tasks
end
- test 'requiring the rake task should not define method .app_generator on Object' do
+ test "requiring the rake task should not define method .app_generator on Object" do
require "#{app_path}/config/environment"
load_tasks
@@ -33,7 +33,7 @@ module ApplicationTests
end
end
- test 'requiring the rake task should not define method .invoke_from_app_generator on Object' do
+ test "requiring the rake task should not define method .invoke_from_app_generator on Object" do
require "#{app_path}/config/environment"
load_tasks
diff --git a/railties/test/application/rake/migrations_test.rb b/railties/test/application/rake/migrations_test.rb
index 35f14a9b84..b3e95769fa 100644
--- a/railties/test/application/rake/migrations_test.rb
+++ b/railties/test/application/rake/migrations_test.rb
@@ -12,7 +12,7 @@ module ApplicationTests
teardown_app
end
- test 'running migrations with given scope' do
+ test "running migrations with given scope" do
Dir.chdir(app_path) do
`bin/rails generate model user username:string password:string`
@@ -37,7 +37,7 @@ module ApplicationTests
end
end
- test 'model and migration generator with change syntax' do
+ test "model and migration generator with change syntax" do
Dir.chdir(app_path) do
`bin/rails generate model user username:string password:string;
bin/rails generate migration add_email_to_users email:string`
@@ -56,12 +56,12 @@ module ApplicationTests
end
end
- test 'migration status when schema migrations table is not present' do
+ test "migration status when schema migrations table is not present" do
output = Dir.chdir(app_path){ `bin/rails db:migrate:status 2>&1` }
assert_equal "Schema migrations table does not exist yet.\n", output
end
- test 'test migration status' do
+ test "test migration status" do
Dir.chdir(app_path) do
`bin/rails generate model user username:string password:string;
bin/rails generate migration add_email_to_users email:string;
@@ -80,8 +80,8 @@ module ApplicationTests
end
end
- test 'migration status without timestamps' do
- add_to_config('config.active_record.timestamped_migrations = false')
+ test "migration status without timestamps" do
+ add_to_config("config.active_record.timestamped_migrations = false")
Dir.chdir(app_path) do
`bin/rails generate model user username:string password:string;
@@ -101,7 +101,7 @@ module ApplicationTests
end
end
- test 'test migration status after rollback and redo' do
+ test "test migration status after rollback and redo" do
Dir.chdir(app_path) do
`bin/rails generate model user username:string password:string;
bin/rails generate migration add_email_to_users email:string;
@@ -126,8 +126,8 @@ module ApplicationTests
end
end
- test 'migration status after rollback and redo without timestamps' do
- add_to_config('config.active_record.timestamped_migrations = false')
+ test "migration status after rollback and redo without timestamps" do
+ add_to_config("config.active_record.timestamped_migrations = false")
Dir.chdir(app_path) do
`bin/rails generate model user username:string password:string;
@@ -153,7 +153,7 @@ module ApplicationTests
end
end
- test 'running migrations with not timestamp head migration files' do
+ test "running migrations with not timestamp head migration files" do
Dir.chdir(app_path) do
app_file "db/migrate/1_one_migration.rb", <<-MIGRATION
@@ -175,8 +175,8 @@ module ApplicationTests
end
end
- test 'schema generation when dump_schema_after_migration is set' do
- add_to_config('config.active_record.dump_schema_after_migration = false')
+ test "schema generation when dump_schema_after_migration is set" do
+ add_to_config("config.active_record.dump_schema_after_migration = false")
Dir.chdir(app_path) do
`bin/rails generate model book title:string`
@@ -187,7 +187,7 @@ module ApplicationTests
assert !File.exist?("db/schema.rb"), "should not dump schema when configured not to"
end
- add_to_config('config.active_record.dump_schema_after_migration = true')
+ add_to_config("config.active_record.dump_schema_after_migration = true")
Dir.chdir(app_path) do
`bin/rails generate model reviews book_id:integer`
@@ -198,7 +198,7 @@ module ApplicationTests
end
end
- test 'default schema generation after migration' do
+ test "default schema generation after migration" do
Dir.chdir(app_path) do
`bin/rails generate model book title:string;
bin/rails db:migrate`
@@ -208,7 +208,7 @@ module ApplicationTests
end
end
- test 'test migration status migrated file is deleted' do
+ test "test migration status migrated file is deleted" do
Dir.chdir(app_path) do
`bin/rails generate model user username:string password:string;
bin/rails generate migration add_email_to_users email:string;
@@ -216,7 +216,7 @@ module ApplicationTests
rm db/migrate/*email*.rb`
output = `bin/rails db:migrate:status`
- File.write('test.txt', output)
+ File.write("test.txt", output)
assert_match(/up\s+\d{14}\s+Create users/, output)
assert_match(/up\s+\d{14}\s+\** NO FILE \**/, output)
diff --git a/railties/test/application/rake/notes_test.rb b/railties/test/application/rake/notes_test.rb
index 7d1e3efed2..c0ff3af193 100644
--- a/railties/test/application/rake/notes_test.rb
+++ b/railties/test/application/rake/notes_test.rb
@@ -1,5 +1,5 @@
require "isolation/abstract_unit"
-require 'rails/source_annotation_extractor'
+require "rails/source_annotation_extractor"
module ApplicationTests
module RakeTests
@@ -17,15 +17,15 @@ module ApplicationTests
teardown_app
end
- test 'notes finds notes for certain file_types' do
+ test "notes finds notes for certain file_types" do
app_file "app/views/home/index.html.erb", "<% # TODO: note in erb %>"
app_file "app/assets/javascripts/application.js", "// TODO: note in js"
app_file "app/assets/stylesheets/application.css", "// TODO: note in css"
app_file "app/controllers/application_controller.rb", 1000.times.map { "" }.join("\n") << "# TODO: note in ruby"
app_file "lib/tasks/task.rake", "# TODO: note in rake"
- app_file 'app/views/home/index.html.builder', '# TODO: note in builder'
- app_file 'config/locales/en.yml', '# TODO: note in yml'
- app_file 'config/locales/en.yaml', '# TODO: note in yaml'
+ app_file "app/views/home/index.html.builder", "# TODO: note in builder"
+ app_file "config/locales/en.yml", "# TODO: note in yml"
+ app_file "config/locales/en.yaml", "# TODO: note in yaml"
app_file "app/views/home/index.ruby", "# TODO: note in ruby"
run_rake_notes do |output, lines|
@@ -43,7 +43,7 @@ module ApplicationTests
end
end
- test 'notes finds notes in default directories' do
+ test "notes finds notes in default directories" do
app_file "app/controllers/some_controller.rb", "# TODO: note in app directory"
app_file "config/initializers/some_initializer.rb", "# TODO: note in config directory"
app_file "db/some_seeds.rb", "# TODO: note in db directory"
@@ -65,7 +65,7 @@ module ApplicationTests
end
end
- test 'notes finds notes in custom directories' do
+ test "notes finds notes in custom directories" do
app_file "app/controllers/some_controller.rb", "# TODO: note in app directory"
app_file "config/initializers/some_initializer.rb", "# TODO: note in config directory"
app_file "db/some_seeds.rb", "# TODO: note in db directory"
@@ -88,7 +88,7 @@ module ApplicationTests
end
end
- test 'custom rake task finds specific notes in specific directories' do
+ test "custom rake task finds specific notes in specific directories" do
app_file "app/controllers/some_controller.rb", "# TODO: note in app directory"
app_file "lib/some_file.rb", "# OPTIMIZE: note in lib directory\n" << "# FIXME: note in lib directory"
app_file "test/some_test.rb", 1000.times.map { "" }.join("\n") << "# TODO: note in test directory"
@@ -113,7 +113,7 @@ module ApplicationTests
end
end
- test 'register a new extension' do
+ test "register a new extension" do
add_to_config "config.assets.precompile = []"
add_to_config %q{ config.annotations.register_extensions("scss", "sass") { |annotation| /\/\/\s*(#{annotation}):?\s*(.*)$/ } }
app_file "app/assets/stylesheets/application.css.scss", "// TODO: note in scss"
@@ -126,7 +126,7 @@ module ApplicationTests
end
end
- test 'register additional directories' do
+ test "register additional directories" do
app_file "spec/spec_helper.rb", "# TODO: note in spec"
app_file "spec/models/user_spec.rb", "# TODO: note in model spec"
add_to_config %q{ config.annotations.register_directories("spec") }
@@ -140,7 +140,7 @@ module ApplicationTests
private
- def run_rake_notes(command = 'bin/rails notes')
+ def run_rake_notes(command = "bin/rails notes")
boot_rails
load_tasks
@@ -153,9 +153,9 @@ module ApplicationTests
end
def load_tasks
- require 'rake'
- require 'rdoc/task'
- require 'rake/testtask'
+ require "rake"
+ require "rdoc/task"
+ require "rake/testtask"
Rails.application.load_tasks
end
diff --git a/railties/test/application/rake/restart_test.rb b/railties/test/application/rake/restart_test.rb
index 78769a6de5..28da8164a7 100644
--- a/railties/test/application/rake/restart_test.rb
+++ b/railties/test/application/rake/restart_test.rb
@@ -13,7 +13,7 @@ module ApplicationTests
teardown_app
end
- test 'rake restart touches tmp/restart.txt' do
+ test "rake restart touches tmp/restart.txt" do
Dir.chdir(app_path) do
`rake restart`
assert File.exist?("tmp/restart.txt")
@@ -26,15 +26,15 @@ module ApplicationTests
end
end
- test 'rake restart should work even if tmp folder does not exist' do
+ test "rake restart should work even if tmp folder does not exist" do
Dir.chdir(app_path) do
- FileUtils.remove_dir('tmp')
+ FileUtils.remove_dir("tmp")
`rake restart`
- assert File.exist?('tmp/restart.txt')
+ assert File.exist?("tmp/restart.txt")
end
end
- test 'rake restart removes server.pid also' do
+ test "rake restart removes server.pid also" do
Dir.chdir(app_path) do
FileUtils.mkdir_p("tmp/pids")
FileUtils.touch("tmp/pids/server.pid")