From 5c07c33ab4de037aeb1f6cc6817fddd28f9a35d2 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 4 Feb 2010 09:28:41 -0800 Subject: Move framework requires and Bundler.require from boot.rb to app.rb. Cut down the list of railtie choices to those that make sense. --- railties/test/generators/app_generator_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/test') diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 76579adb26..9c70dcbc92 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -90,7 +90,7 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_activerecord_is_removed_from_frameworks_if_skip_activerecord_is_given run_generator [destination_root, "--skip-activerecord"] - assert_file "config/boot.rb", /# require "active_record\/railtie"/ + assert_file "config/application.rb", /# require "active_record\/railtie"/ end def test_prototype_and_test_unit_are_added_by_default -- cgit v1.2.3 From b392c818692b39b09836071a30e7a65034e752b5 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Fri, 5 Feb 2010 21:30:26 -0800 Subject: Fixes test fail --- railties/test/generators/app_generator_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/test') diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 9c70dcbc92..54b970c0ab 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -158,7 +158,7 @@ class AppGeneratorTest < Rails::Generators::TestCase generator([destination_root], :dev => true).expects(:run).with("bundle install") silence(:stdout){ generator.invoke } rails_path = File.expand_path('../../..', Rails.root) - dev_gem = %(path #{rails_path.inspect}, :glob => "{*/,}*.gemspec") + dev_gem = %(gem "rails", :path => #{rails_path.inspect}) assert_file 'Gemfile', /^#{Regexp.escape(dev_gem)}$/ end -- cgit v1.2.3 From 6958eac1a00a4ab33e3facc70c80a07492288196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 6 Feb 2010 17:32:06 +0100 Subject: Add config.generators.templates to provide alternative paths for template lookup. --- railties/test/application/generators_test.rb | 15 ++++----------- railties/test/generators/generators_test_helper.rb | 1 + 2 files changed, 5 insertions(+), 11 deletions(-) (limited to 'railties/test') diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb index 25fa100275..712c8bef36 100644 --- a/railties/test/application/generators_test.rb +++ b/railties/test/application/generators_test.rb @@ -52,30 +52,23 @@ module ApplicationTests end end - test "generators set rails fallbacks" do - with_config do |c| - c.generators.fallbacks[:shoulda] = :test_unit - expected = { :shoulda => :test_unit } - assert_equal expected, c.generators.fallbacks - end - end - - test "generators aliases, options and fallbacks on initialization" do + test "generators aliases, options, templates and fallbacks on initialization" do add_to_config <<-RUBY config.generators.rails :aliases => { :test_framework => "-w" } config.generators.orm :datamapper config.generators.test_framework :rspec config.generators.fallbacks[:shoulda] = :test_unit + config.generators.templates << "some/where" RUBY # Initialize the application require "#{app_path}/config/environment" require "rails/generators" - Rails::Generators.configure! assert_equal :rspec, Rails::Generators.options[:rails][:test_framework] assert_equal "-w", Rails::Generators.aliases[:rails][:test_framework] - assert_equal :test_unit, Rails::Generators.fallbacks[:shoulda] + assert_equal Hash[:shoulda => :test_unit], Rails::Generators.fallbacks + assert_equal ["#{app_path}/lib/templates", "some/where"], Rails::Generators.templates_path end test "generators no color on initialization" do diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb index 3cd16a69f9..32be99b144 100644 --- a/railties/test/generators/generators_test_helper.rb +++ b/railties/test/generators/generators_test_helper.rb @@ -6,6 +6,7 @@ module Rails end end Rails.application.config.root = Rails.root +Rails.application.config.generators.templates = [File.join(Rails.root, "lib", "templates")] require 'rails/generators' require 'rails/generators/test_case' -- cgit v1.2.3 From f44a0b1d524064a2e919cd10d3013db680af9b17 Mon Sep 17 00:00:00 2001 From: RomD Date: Sat, 6 Feb 2010 17:18:10 +0100 Subject: fix usage examples and more to use new invocations Signed-off-by: Carl Lerche --- railties/test/generators/actions_test.rb | 10 +++++----- railties/test/isolation/abstract_unit.rb | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'railties/test') diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index cb1fa96e0d..0512f69f4a 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -36,22 +36,22 @@ class ActionsTest < Rails::Generators::TestCase end def test_plugin_with_git_option_should_run_plugin_install - generator.expects(:run_ruby_script).once.with("script/plugin install #{@git_plugin_uri}", :verbose => false) + 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 def test_plugin_with_svn_option_should_run_plugin_install - generator.expects(:run_ruby_script).once.with("script/plugin install #{@svn_plugin_uri}", :verbose => false) + 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 def test_plugin_with_git_option_and_branch_should_run_plugin_install - generator.expects(:run_ruby_script).once.with("script/plugin install -b stable #{@git_plugin_uri}", :verbose => false) + 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 def test_plugin_with_svn_option_and_revision_should_run_plugin_install - generator.expects(:run_ruby_script).once.with("script/plugin install -r 1234 #{@svn_plugin_uri}", :verbose => false) + 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 @@ -155,7 +155,7 @@ class ActionsTest < Rails::Generators::TestCase end def test_generate_should_run_script_generate_with_argument_and_options - generator.expects(:run_ruby_script).once.with('script/generate model MyModel', :verbose => false) + generator.expects(:run_ruby_script).once.with('script/rails generate model MyModel', :verbose => false) action :generate, 'model', 'MyModel' end diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index dcadf3f485..364dbd8e55 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -154,7 +154,7 @@ module TestHelpers def script(script) Dir.chdir(app_path) do - `#{Gem.ruby} #{app_path}/script/#{script}` + `#{Gem.ruby} #{app_path}/script/rails #{script}` end end -- cgit v1.2.3 From 518b4ff478984b74085239b0aa69fe67f7c01d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 7 Feb 2010 14:36:50 +0100 Subject: Check if Test::Unit is defined before adding backtrace filter. --- railties/test/application/test_test.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'railties/test') diff --git a/railties/test/application/test_test.rb b/railties/test/application/test_test.rb index 37175783d8..de316a6fd0 100644 --- a/railties/test/application/test_test.rb +++ b/railties/test/application/test_test.rb @@ -23,6 +23,23 @@ module ApplicationTests run_test 'unit/foo_test.rb' end + # Run just in Ruby < 1.9 + if defined?(Test::Unit::Util::BacktraceFilter) + test "adds backtrace cleaner" do + app_file 'test/unit/backtrace_test.rb', <<-RUBY + require 'test_helper' + + class FooTest < ActiveSupport::TestCase + def test_truth + assert Test::Unit::Util::BacktraceFilter.ancestors.include?(Rails::BacktraceFilterForTestUnit) + end + end + RUBY + + run_test 'unit/backtrace_test.rb' + end + end + test "integration test" do controller 'posts', <<-RUBY class PostsController < ActionController::Base -- cgit v1.2.3 From 7d76474e5da6c1c06eb831fe436f12591cca4339 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Wed, 10 Feb 2010 16:51:14 +1100 Subject: Debrittlize tests somewhat - fix for CI build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/test/generators/app_generator_test.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'railties/test') diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 54b970c0ab..d0cd72a47b 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -74,13 +74,13 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_config_database_is_added_by_default run_generator assert_file "config/database.yml", /sqlite3/ - assert_file "Gemfile", /^gem "sqlite3-ruby", :require => "sqlite3"$/ + assert_file "Gemfile", /^gem\s+["']sqlite3-ruby["'],\s+:require\s+=>\s+["']sqlite3["']$/ end def test_config_another_database run_generator([destination_root, "-d", "mysql"]) assert_file "config/database.yml", /mysql/ - assert_file "Gemfile", /^gem "mysql"$/ + assert_file "Gemfile", /^gem\s+["']mysql["']$/ end def test_config_database_is_not_added_if_skip_activerecord_is_given @@ -90,7 +90,7 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_activerecord_is_removed_from_frameworks_if_skip_activerecord_is_given run_generator [destination_root, "--skip-activerecord"] - assert_file "config/application.rb", /# require "active_record\/railtie"/ + assert_file "config/application.rb", /#\s+require\s+["']active_record\/railtie["']/ end def test_prototype_and_test_unit_are_added_by_default @@ -159,14 +159,14 @@ class AppGeneratorTest < Rails::Generators::TestCase silence(:stdout){ generator.invoke } rails_path = File.expand_path('../../..', Rails.root) dev_gem = %(gem "rails", :path => #{rails_path.inspect}) - assert_file 'Gemfile', /^#{Regexp.escape(dev_gem)}$/ + assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:path\s+=>\s+["']\/Users\/mikel\/rails_programs\/rails["']$/ end def test_edge_option generator([destination_root], :edge => true).expects(:run).with("bundle install") silence(:stdout){ generator.invoke } edge_gem = %(gem "rails", :git => "git://github.com/rails/rails.git") - assert_file 'Gemfile', /^#{Regexp.escape(edge_gem)}$/ + assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:git\s+=>\s+["']git:\/\/github\.com\/rails\/rails\.git["']$/ end protected -- cgit v1.2.3 From 9c654744fbc5f3035e07f741997d37f287729103 Mon Sep 17 00:00:00 2001 From: Michael Bleigh Date: Mon, 8 Feb 2010 14:58:32 -0500 Subject: Fixes unescaped version passthrough of generator 'gem' command. [#3901 status:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/test/generators/actions_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'railties/test') diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index 0512f69f4a..5929db6318 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -103,6 +103,24 @@ class ActionsTest < Rails::Generators::TestCase assert_file 'Gemfile', /gem "rspec", :only => \["development", "test"\]/ end + 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 + + def test_gem_should_insert_on_separate_lines + run_generator + + action :gem, 'rspec' + action :gem, 'rspec-rails' + + assert_file 'Gemfile', /gem "rspec"$/ + assert_file 'Gemfile', /gem "rspec-rails"$/ + end + def test_environment_should_include_data_in_environment_initializer_block run_generator load_paths = 'config.load_paths += %w["#{Rails.root}/app/extras"]' -- cgit v1.2.3 From 97650bf54a8c50cd7ee9e41a500503d9be5b5b5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 10 Feb 2010 08:33:41 +0100 Subject: Fix a couple failing tests. --- railties/test/generators/app_generator_test.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'railties/test') diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index d0cd72a47b..0a746b200f 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -158,15 +158,13 @@ class AppGeneratorTest < Rails::Generators::TestCase generator([destination_root], :dev => true).expects(:run).with("bundle install") silence(:stdout){ generator.invoke } rails_path = File.expand_path('../../..', Rails.root) - dev_gem = %(gem "rails", :path => #{rails_path.inspect}) - assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:path\s+=>\s+["']\/Users\/mikel\/rails_programs\/rails["']$/ + assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:path\s+=>\s+["']#{Regexp.escape(rails_path)}["']$/ end def test_edge_option generator([destination_root], :edge => true).expects(:run).with("bundle install") silence(:stdout){ generator.invoke } - edge_gem = %(gem "rails", :git => "git://github.com/rails/rails.git") - assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:git\s+=>\s+["']git:\/\/github\.com\/rails\/rails\.git["']$/ + assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:git\s+=>\s+["']#{Regexp.escape("git://github.com/rails/rails.git")}["']$/ end protected -- cgit v1.2.3