Remove integration tests and ActionModel/ActiveRecord calls from 'rake plugin new' generator, it shouldn't be available as default option

This commit is contained in:
Piotr Sarnacki
2010-10-23 18:24:04 +02:00
parent ac8f9276f5
commit 68295bc693
8 changed files with 7 additions and 43 deletions

View File

@@ -215,8 +215,9 @@ end
def application_definition
@application_definition ||= begin
unless options[:pretend]
contents = File.read(File.expand_path("#{dummy_path}/config/application.rb", destination_root))
dummy_application_path = File.expand_path("#{dummy_path}/config/application.rb", destination_root)
unless options[:pretend] || !File.exists?(dummy_application_path)
contents = File.read(dummy_application_path)
contents[(contents.index("module Dummy"))..-1]
end
end

View File

@@ -2,9 +2,6 @@ source "http://rubygems.org"
<%= rails_gemfile_entry -%>
gem "capybara", ">= 0.3.9"
gem "sqlite3-ruby", :require => "sqlite3"
if RUBY_VERSION < '1.9'
gem "ruby-debug", ">= 0.10.3"
end

View File

@@ -1,10 +1,6 @@
require File.expand_path('../boot', __FILE__)
require "active_model/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_view/railtie"
require "action_mailer/railtie"
require 'rails/all'
Bundler.require
require "<%= name %>"

View File

@@ -1,7 +0,0 @@
require 'test_helper'
class NagivationTest < ActiveSupport::IntegrationCase
test "truth" do
assert_kind_of Dummy::Application, Rails.application
end
end

View File

@@ -1,5 +0,0 @@
# Define a bare test case to use with Capybara
class ActiveSupport::IntegrationCase < ActiveSupport::TestCase
include Capybara
include Rails.application.routes.url_helpers
end

View File

@@ -4,19 +4,7 @@ ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require "rails/test_help"
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.default_url_options[:host] = "test.com"
Rails.backtrace_cleaner.remove_silencers!
# Configure capybara for integration testing
require "capybara/rails"
Capybara.default_driver = :rack_test
Capybara.default_selector = :css
# Run any available migration
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }

View File

@@ -145,7 +145,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
def test_test_unit_is_skipped_if_required
run_generator [destination_root, "--skip-test-unit"]
assert_no_file "test"
assert_no_file "test"
end
def test_javascript_is_skipped_if_required

View File

@@ -13,8 +13,6 @@ DEFAULT_PLUGIN_FILES = %w(
lib/bukkits.rb
script/rails
test/bukkits_test.rb
test/integration/navigation_test.rb
test/support/integration_case.rb
test/test_helper.rb
test/dummy
)
@@ -43,12 +41,8 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
def test_generating_test_files
run_generator
assert_file "test/test_helper.rb"
assert_directory "test/support/"
assert_directory "test/integration/"
assert_file "test/bukkits_test.rb", /assert_kind_of Module, Bukkits/
assert_file "test/integration/navigation_test.rb", /assert_kind_of Dummy::Application, Rails.application/
assert_file "test/support/integration_case.rb", /class ActiveSupport::IntegrationCase/
end
def test_ensure_that_plugin_options_are_not_passed_app_generator
@@ -66,7 +60,7 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
run_generator
FileUtils.cd destination_root
`bundle install`
assert_match /2 tests, 2 assertions, 0 failures, 0 errors/, `bundle exec rake test`
assert_match /1 tests, 1 assertions, 0 failures, 0 errors/, `bundle exec rake test`
end
protected