1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/test/generators/session_migration_generator_test.rb
Akira Matsuda cce461511b be sure to parenthesize the arguments when the first one is a RegExp literal
this fixes: "warning: ambiguous first argument; put parentheses or even spaces"
because: you need this to tell the parser that you're not calling :/ method (division)
details (Japanese!): http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-dev/42445?42370-43277
2011-05-18 23:20:19 +09:00

27 lines
1 KiB
Ruby

require 'generators/generators_test_helper'
require 'rails/generators/rails/session_migration/session_migration_generator'
class SessionMigrationGeneratorTest < Rails::Generators::TestCase
include GeneratorsTestHelper
def test_session_migration_with_default_name
run_generator
assert_migration "db/migrate/add_sessions_table.rb", /class AddSessionsTable < ActiveRecord::Migration/
end
def test_session_migration_with_given_name
run_generator ["create_session_table"]
assert_migration "db/migrate/create_session_table.rb", /class CreateSessionTable < ActiveRecord::Migration/
end
def test_session_migration_with_custom_table_name
ActiveRecord::SessionStore::Session.table_name = "custom_table_name"
run_generator
assert_migration "db/migrate/add_sessions_table.rb" do |migration|
assert_match(/class AddSessionsTable < ActiveRecord::Migration/, migration)
assert_match(/create_table :custom_table_name/, migration)
end
ensure
ActiveRecord::SessionStore::Session.table_name = "sessions"
end
end