Methods
A
S
T
Included Modules
Instance Public methods
setup()
# File railties/test/generators/actions_test.rb, line 9
def setup
  Rails.application = TestApp::Application
  super
  @git_plugin_uri = 'git://github.com/technoweenie/restful-authentication.git'
  @svn_plugin_uri = 'svn://svnhub.com/technoweenie/restful-authentication/trunk'
end
teardown()
# File railties/test/generators/actions_test.rb, line 16
def teardown
  Rails.application = TestApp::Application.instance
end
test_add_source_adds_source_to_gemfile()
# File railties/test/generators/actions_test.rb, line 75
def test_add_source_adds_source_to_gemfile
  run_generator
  action :add_source, 'http://gems.github.com'
  assert_file 'Gemfile', /source "http:\/\/gems\.github\.com"/
end
test_capify_should_run_the_capify_command()
# File railties/test/generators/actions_test.rb, line 221
def test_capify_should_run_the_capify_command
  generator.expects(:run).once.with('capify .', :verbose => false)
  action :capify!
end
test_create_file_should_write_block_contents_to_file_path()
# File railties/test/generators/actions_test.rb, line 35
def test_create_file_should_write_block_contents_to_file_path
  action(:create_file, 'lib/test_file.rb'){ 'heres block data' }
  assert_file 'lib/test_file.rb', 'heres block data'
end
test_create_file_should_write_data_to_file_path()
# File railties/test/generators/actions_test.rb, line 30
def test_create_file_should_write_data_to_file_path
  action :create_file, 'lib/test_file.rb', 'heres test data'
  assert_file 'lib/test_file.rb', 'heres test data'
end
test_env_option_should_win_over_rails_env_variable_when_running_rake()
# File railties/test/generators/actions_test.rb, line 205
def test_env_option_should_win_over_rails_env_variable_when_running_rake
  generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', :verbose => false)
  old_env, ENV["RAILS_ENV"] = ENV["RAILS_ENV"], "staging"
  action :rake, 'log:clear', :env => 'production'
ensure
  ENV["RAILS_ENV"] = old_env
end
test_environment_should_include_data_in_environment_initializer_block()
# File railties/test/generators/actions_test.rb, line 121
def test_environment_should_include_data_in_environment_initializer_block
  run_generator
  autoload_paths = 'config.autoload_paths += %w["#{Rails.root}/app/extras"]'
  action :environment, autoload_paths
  assert_file 'config/application.rb', /  class Application < Rails::Application\n    #{Regexp.escape(autoload_paths)}/
end
test_environment_should_include_data_in_environment_initializer_block_with_env_option()
# File railties/test/generators/actions_test.rb, line 128
def test_environment_should_include_data_in_environment_initializer_block_with_env_option
  run_generator
  autoload_paths = 'config.autoload_paths += %w["#{Rails.root}/app/extras"]'
  action :environment, autoload_paths, :env => 'development'
  assert_file "config/environments/development.rb", /Application\.configure do\n  #{Regexp.escape(autoload_paths)}/
end
test_environment_with_block_should_include_block_contents_in_environment_initializer_block()
# File railties/test/generators/actions_test.rb, line 135
def test_environment_with_block_should_include_block_contents_in_environment_initializer_block
  run_generator

  action :environment do
    '# This wont be added'
    '# This will be added'
  end

  assert_file 'config/application.rb' do |content|
    assert_match(/# This will be added/, content)
    assert_no_match(/# This wont be added/, content)
  end
end
test_gem_group_should_wrap_gems_in_a_group()
# File railties/test/generators/actions_test.rb, line 107
def test_gem_group_should_wrap_gems_in_a_group
  run_generator

  action :gem_group, :development, :test do
    gem 'rspec-rails'
  end

  action :gem_group, :test do
    gem 'fakeweb'
  end

  assert_file 'Gemfile', /\ngroup :development, :test do\n  gem "rspec-rails"\nend\n\ngroup :test do\n  gem "fakeweb"\nend/
end
test_gem_should_insert_on_separate_lines()
# File railties/test/generators/actions_test.rb, line 95
def test_gem_should_insert_on_separate_lines
  run_generator

  File.open('Gemfile', 'a') {|f| f.write('# Some content...') }

  action :gem, 'rspec'
  action :gem, 'rspec-rails'

  assert_file 'Gemfile', /^gem "rspec"$/
  assert_file 'Gemfile', /^gem "rspec-rails"$/
end
test_gem_should_put_gem_dependency_in_gemfile()
# File railties/test/generators/actions_test.rb, line 81
def test_gem_should_put_gem_dependency_in_gemfile
  run_generator
  action :gem, 'will-paginate'
  assert_file 'Gemfile', /gem "will\-paginate"/
end
test_gem_with_version_should_include_version_in_gemfile()
# File railties/test/generators/actions_test.rb, line 87
def test_gem_with_version_should_include_version_in_gemfile
  run_generator

  action :gem, 'rspec', '>=2.0.0.a5'

  assert_file 'Gemfile', /gem "rspec", ">=2.0.0.a5"/
end
test_generate_should_run_script_generate_with_argument_and_options()
# File railties/test/generators/actions_test.rb, line 179
def test_generate_should_run_script_generate_with_argument_and_options
  generator.expects(:run_ruby_script).once.with('script/rails generate model MyModel', :verbose => false)
  action :generate, 'model', 'MyModel'
end
test_git_with_hash_should_run_each_command_using_git_scm()
# File railties/test/generators/actions_test.rb, line 154
def test_git_with_hash_should_run_each_command_using_git_scm
  generator.expects(:run).times(2)
  action :git, :rm => 'README', :add => '.'
end
test_git_with_symbol_should_run_command_using_git_scm()
# File railties/test/generators/actions_test.rb, line 149
def test_git_with_symbol_should_run_command_using_git_scm
  generator.expects(:run).once.with('git init')
  action :git, :init
end
test_initializer_should_write_date_to_file_in_config_initializers()
# File railties/test/generators/actions_test.rb, line 174
def test_initializer_should_write_date_to_file_in_config_initializers
  action :initializer, 'constants.rb', 'MY_CONSTANT = 42'
  assert_file 'config/initializers/constants.rb', 'MY_CONSTANT = 42'
end
test_invoke_other_generator_with_full_namespace()
# File railties/test/generators/actions_test.rb, line 25
def test_invoke_other_generator_with_full_namespace
  action :invoke, 'rails:model', ['my_model']
  assert_file 'app/models/my_model.rb', /MyModel/
end
test_invoke_other_generator_with_shortcut()
# File railties/test/generators/actions_test.rb, line 20
def test_invoke_other_generator_with_shortcut
  action :invoke, 'model', ['my_model']
  assert_file 'app/models/my_model.rb', /MyModel/
end
test_lib_should_write_data_to_file_in_lib()
# File railties/test/generators/actions_test.rb, line 164
def test_lib_should_write_data_to_file_in_lib
  action :lib, 'my_library.rb', 'class MyLibrary'
  assert_file 'lib/my_library.rb', 'class MyLibrary'
end
test_log()
# File railties/test/generators/actions_test.rb, line 246
def test_log
  assert_equal("YES\n", action(:log, "YES"))
end
test_log_with_quiet()
# File railties/test/generators/actions_test.rb, line 254
def test_log_with_quiet
  generator(default_arguments, :quiet => true)
  assert_equal("", action(:log, "YES"))
end
test_log_with_status()
# File railties/test/generators/actions_test.rb, line 250
def test_log_with_status
  assert_equal("         yes  YES\n", action(:log, :yes, "YES"))
end
test_log_with_status_with_quiet()
# File railties/test/generators/actions_test.rb, line 259
def test_log_with_status_with_quiet
  generator(default_arguments, :quiet => true)
  assert_equal("", action(:log, :yes, "YES"))
end
test_plugin_with_git_option_and_branch_should_run_plugin_install()
# File railties/test/generators/actions_test.rb, line 50
def test_plugin_with_git_option_and_branch_should_run_plugin_install
  generator.expects(:run_ruby_script).once.with("script/rails plugin install -b stable #{@git_plugin_uri}", :verbose => false)
  action :plugin, 'restful-authentication', :git => @git_plugin_uri, :branch => 'stable'
end
test_plugin_with_git_option_and_submodule_should_use_git_scm()
# File railties/test/generators/actions_test.rb, line 60
def test_plugin_with_git_option_and_submodule_should_use_git_scm
  generator.expects(:run).with("git submodule add #{@git_plugin_uri} vendor/plugins/rest_auth", :verbose => false)
  action :plugin, 'rest_auth', :git => @git_plugin_uri, :submodule => true
end
test_plugin_with_git_option_should_run_plugin_install()
# File railties/test/generators/actions_test.rb, line 40
def test_plugin_with_git_option_should_run_plugin_install
  generator.expects(:run_ruby_script).once.with("script/rails plugin install #{@git_plugin_uri}", :verbose => false)
  action :plugin, 'restful-authentication', :git => @git_plugin_uri
end
test_plugin_with_no_options_should_skip_method()
# File railties/test/generators/actions_test.rb, line 70
def test_plugin_with_no_options_should_skip_method
  generator.expects(:run).never
  action :plugin, 'rest_auth', {}
end
test_plugin_with_svn_option_and_revision_should_run_plugin_install()
# File railties/test/generators/actions_test.rb, line 55
def test_plugin_with_svn_option_and_revision_should_run_plugin_install
  generator.expects(:run_ruby_script).once.with("script/rails plugin install -r 1234 #{@svn_plugin_uri}", :verbose => false)
  action :plugin, 'restful-authentication', :svn => @svn_plugin_uri, :revision => 1234
end
test_plugin_with_svn_option_should_run_plugin_install()
# File railties/test/generators/actions_test.rb, line 45
def test_plugin_with_svn_option_should_run_plugin_install
  generator.expects(:run_ruby_script).once.with("script/rails plugin install #{@svn_plugin_uri}", :verbose => false)
  action :plugin, 'restful-authentication', :svn => @svn_plugin_uri
end
test_rake_should_run_rake_command_with_default_env()
# File railties/test/generators/actions_test.rb, line 184
def test_rake_should_run_rake_command_with_default_env
  generator.expects(:run).once.with("rake log:clear RAILS_ENV=development", :verbose => false)
  old_env, ENV['RAILS_ENV'] = ENV["RAILS_ENV"], nil
  action :rake, 'log:clear'
ensure
  ENV["RAILS_ENV"] = old_env
end
test_rake_with_env_option_should_run_rake_command_in_env()
# File railties/test/generators/actions_test.rb, line 192
def test_rake_with_env_option_should_run_rake_command_in_env
  generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', :verbose => false)
  action :rake, 'log:clear', :env => 'production'
end
test_rake_with_rails_env_variable_should_run_rake_command_in_env()
# File railties/test/generators/actions_test.rb, line 197
def test_rake_with_rails_env_variable_should_run_rake_command_in_env
  generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', :verbose => false)
  old_env, ENV["RAILS_ENV"] = ENV["RAILS_ENV"], "production"
  action :rake, 'log:clear'
ensure
  ENV["RAILS_ENV"] = old_env
end
test_rake_with_sudo_option_should_run_rake_command_with_sudo()
# File railties/test/generators/actions_test.rb, line 213
def test_rake_with_sudo_option_should_run_rake_command_with_sudo
  generator.expects(:run).once.with("sudo rake log:clear RAILS_ENV=development", :verbose => false)
  old_env, ENV['RAILS_ENV'] = ENV["RAILS_ENV"], nil
  action :rake, 'log:clear', :sudo => true
ensure
  ENV["RAILS_ENV"] = old_env
end
test_rakefile_should_write_date_to_file_in_lib_tasks()
# File railties/test/generators/actions_test.rb, line 169
def test_rakefile_should_write_date_to_file_in_lib_tasks
  action :rakefile, 'myapp.rake', 'task :run => [:environment]'
  assert_file 'lib/tasks/myapp.rake', 'task :run => [:environment]'
end
test_readme()
# File railties/test/generators/actions_test.rb, line 233
def test_readme
  run_generator
  Rails::Generators::AppGenerator.expects(:source_root).times(2).returns(destination_root)
  assert_match(/Welcome to Rails/, action(:readme, "README.rdoc"))
end
test_readme_with_quiet()
# File railties/test/generators/actions_test.rb, line 239
def test_readme_with_quiet
  generator(default_arguments, :quiet => true)
  run_generator
  Rails::Generators::AppGenerator.expects(:source_root).times(2).returns(destination_root)
  assert_no_match(/Welcome to Rails/, action(:readme, "README.rdoc"))
end
test_route_should_add_data_to_the_routes_block_in_config_routes()
# File railties/test/generators/actions_test.rb, line 226
def test_route_should_add_data_to_the_routes_block_in_config_routes
  run_generator
  route_command = "route '/login', :controller => 'sessions', :action => 'new'"
  action :route, route_command
  assert_file 'config/routes.rb', /#{Regexp.escape(route_command)}/
end
test_vendor_should_write_data_to_file_in_vendor()
# File railties/test/generators/actions_test.rb, line 159
def test_vendor_should_write_data_to_file_in_vendor
  action :vendor, 'vendor_file.rb', '# vendor data'
  assert_file 'vendor/vendor_file.rb', '# vendor data'
end
Instance Protected methods
action(*args, &block)
# File railties/test/generators/actions_test.rb, line 266
def action(*args, &block)
  silence(:stdout){ generator.send(*args, &block) }
end