Permalink
Browse files

Don't test Rails 2

  • Loading branch information...
jferris committed Dec 13, 2010
1 parent 87ff387 commit a01e60a4e7cc9a10516f87d5827251d62c078b8b
Showing with 109 additions and 1,356 deletions.
  1. +5 −23 Rakefile
  2. +1 −2 cucumber.yml
  3. +3 −30 features/rails_integration.feature
  4. +0 −83 features/step_definitions/rails2_steps.rb
  5. +2 −2 features/step_definitions/rails3_steps.rb
  6. +0 −2 lib/shoulda.rb
  7. +14 −5 lib/shoulda/integrations/rspec.rb
  8. +0 −22 lib/shoulda/integrations/rspec2.rb
  9. +0 −130 test/rails2_model_builder.rb
  10. +0 −22 test/rails2_root/app/controllers/application_controller.rb
  11. +0 −87 test/rails2_root/app/controllers/posts_controller.rb
  12. +0 −84 test/rails2_root/app/controllers/users_controller.rb
  13. +0 −3 test/rails2_root/app/helpers/application_helper.rb
  14. +0 −2 test/rails2_root/app/helpers/posts_helper.rb
  15. +0 −2 test/rails2_root/app/helpers/users_helper.rb
  16. +0 −7 test/rails2_root/app/models/address.rb
  17. +0 −11 test/rails2_root/app/models/flea.rb
  18. +0 −4 test/rails2_root/app/models/friendship.rb
  19. +0 −8 test/rails2_root/app/models/notifier.rb
  20. +0 −7 test/rails2_root/app/models/pets/cat.rb
  21. +0 −10 test/rails2_root/app/models/pets/dog.rb
  22. +0 −12 test/rails2_root/app/models/post.rb
  23. +0 −12 test/rails2_root/app/models/product.rb
  24. +0 −2 test/rails2_root/app/models/profile.rb
  25. +0 −2 test/rails2_root/app/models/registration.rb
  26. +0 −8 test/rails2_root/app/models/tag.rb
  27. +0 −4 test/rails2_root/app/models/tagging.rb
  28. +0 −3 test/rails2_root/app/models/treat.rb
  29. +0 −32 test/rails2_root/app/models/user.rb
  30. +0 −19 test/rails2_root/app/views/layouts/posts.rhtml
  31. +0 −17 test/rails2_root/app/views/layouts/users.rhtml
  32. +0 −1 test/rails2_root/app/views/layouts/wide.html.erb
  33. +0 −1 test/rails2_root/app/views/notifier/the_email.html.erb
  34. +0 −27 test/rails2_root/app/views/posts/edit.rhtml
  35. +0 −25 test/rails2_root/app/views/posts/index.rhtml
  36. +0 −26 test/rails2_root/app/views/posts/new.rhtml
  37. +0 −18 test/rails2_root/app/views/posts/show.rhtml
  38. +0 −22 test/rails2_root/app/views/users/edit.rhtml
  39. +0 −22 test/rails2_root/app/views/users/index.rhtml
  40. +0 −21 test/rails2_root/app/views/users/new.rhtml
  41. +0 −13 test/rails2_root/app/views/users/show.rhtml
  42. +0 −110 test/rails2_root/config/boot.rb
  43. +0 −4 test/rails2_root/config/database.yml
  44. +0 −17 test/rails2_root/config/environment.rb
  45. +0 −23 test/rails2_root/config/environments/test.rb
  46. +0 −15 test/rails2_root/config/initializers/new_rails_defaults.rb
  47. +0 −8 test/rails2_root/config/initializers/shoulda.rb
  48. +0 −6 test/rails2_root/config/routes.rb
  49. +0 −19 test/rails2_root/db/migrate/001_create_users.rb
  50. +0 −13 test/rails2_root/db/migrate/002_create_posts.rb
  51. +0 −12 test/rails2_root/db/migrate/003_create_taggings.rb
  52. +0 −11 test/rails2_root/db/migrate/004_create_tags.rb
  53. +0 −12 test/rails2_root/db/migrate/005_create_dogs.rb
  54. +0 −14 test/rails2_root/db/migrate/006_create_addresses.rb
  55. +0 −11 test/rails2_root/db/migrate/007_create_fleas.rb
  56. +0 −12 test/rails2_root/db/migrate/008_create_dogs_fleas.rb
  57. +0 −17 test/rails2_root/db/migrate/009_create_products.rb
  58. +0 −14 test/rails2_root/db/migrate/010_create_friendships.rb
  59. +0 −12 test/rails2_root/db/migrate/011_create_treats.rb
  60. +0 −12 test/rails2_root/db/migrate/20090506203502_create_profiles.rb
  61. +0 −14 test/rails2_root/db/migrate/20090506203536_create_registrations.rb
  62. +0 −12 test/rails2_root/db/migrate/20090513104502_create_cats.rb
  63. 0 test/rails2_root/db/schema.rb
  64. +0 −40 test/rails2_root/public/.htaccess
  65. +0 −30 test/rails2_root/public/404.html
  66. +0 −30 test/rails2_root/public/422.html
  67. +0 −30 test/rails2_root/public/500.html
  68. +0 −3 test/rails2_root/script/console
  69. +0 −3 test/rails2_root/script/generate
  70. 0 test/rails2_root/vendor/plugins/.keep
  71. +0 −6 test/rails2_test_helper.rb
  72. +77 −0 test/rails3_root/Gemfile.lock
  73. 0 test/{rails2_root → rails3_root}/test/shoulda_macros/custom_macro.rb
  74. 0 test/{rails2_root → rails3_root}/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro.rb
  75. 0 test/{rails2_root/log → rails3_root/vendor/plugins}/.keep
  76. 0 test/{rails2_root → rails3_root}/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_macro.rb
  77. +0 −6 test/rails3_test_helper.rb
  78. +7 −7 test/test_helper.rb
View
@@ -45,30 +45,12 @@ end
desc "Clean files generated by rake tasks"
task :clobber => [:clobber_rdoc, :clobber_package]
-namespace :cucumber do
- Cucumber::Rake::Task.new(:rails2, "Run the cucumber features in Rails 2") do |t|
- t.fork = true
- t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
- t.profile = 'rails2'
- end
-
- Cucumber::Rake::Task.new(:rails3, "Run the cucumber features in Rails 3") do |t|
- t.fork = true
- t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
- t.profile = 'rails3'
- end
-end rescue nil
-
-desc "Run the cucumber features in both Rails 2 and 3"
-task :cucumber => ["cucumber:rails2", "cucumber:rails3"]
-
-desc 'run tests for all supported versions of Rails'
-task :test_all do
- %w(2.3.8 3.0.0.beta4).each do |version|
- system("RAILS_VERSION=#{version} rake -s test;")
- end
+Cucumber::Rake::Task.new do |t|
+ t.fork = true
+ t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
+ t.profile = 'default'
end
desc 'Default: run test and cucumber features for support versions'
-task :default => [:test_all, :cucumber]
+task :default => [:test, :cucumber]
View
@@ -1,2 +1 @@
-rails2: -r features/support -r features/step_definitions/common_steps.rb -r features/step_definitions/rails2_steps.rb
-rails3: -r features/support -r features/step_definitions/common_steps.rb -r features/step_definitions/rails3_steps.rb
+default: -r features/support -r features/step_definitions/common_steps.rb -r features/step_definitions/rails3_steps.rb
@@ -2,7 +2,6 @@ Feature: integrate with Rails
Background:
When I generate a new rails application
- And I configure the application to use "shoulda" from this project
And I save the following as "db/migrate/1_create_users.rb"
"""
class CreateUsers < ActiveRecord::Migration
@@ -31,36 +30,9 @@ Feature: integrate with Rails
"""
When I configure a wildcard route
- Scenario: generate a rails application and use macros in Test::Unit
- When I save the following as "test/unit/user_test.rb"
- """
- require 'test_helper'
-
- class UserTest < ActiveSupport::TestCase
- should_validate_presence_of :name
- end
- """
- When I save the following as "test/functional/examples_controller_test.rb"
- """
- require 'test_helper'
-
- class ExamplesControllerTest < ActionController::TestCase
- def setup
- get :show
- end
-
- should_respond_with :success
- should_assign_to :example
- end
- """
- When I run "rake test TESTOPTS=-v"
- Then I should see "1 tests, 1 assertions, 0 failures, 0 errors"
- And I should see "2 tests, 2 assertions, 0 failures, 0 errors"
- And I should see "User should require name to be set"
- And I should see "ExamplesController should assign @example"
-
Scenario: generate a rails application and use matchers in Test::Unit
- When I save the following as "test/unit/user_test.rb"
+ When I configure the application to use "shoulda" from this project
+ And I save the following as "test/unit/user_test.rb"
"""
require 'test_helper'
@@ -89,6 +61,7 @@ Feature: integrate with Rails
Scenario: generate a rails application and use matchers in Rspec
When I configure the application to use rspec-rails
+ And I configure the application to use "shoulda" from this project
And I run the rspec generator
And I save the following as "spec/models/user_spec.rb"
"""
@@ -1,83 +0,0 @@
-When /^I generate a new rails application$/ do
- load_rails = <<-RUBY
- gem 'rails', '2.3.8'; \
- load Gem.bin_path('rails', 'rails', '2.3.8')
- RUBY
-
- @terminal.cd(TEMP_ROOT)
- @terminal.run(%{ruby -rubygems -e "#{load_rails.strip!}" #{APP_NAME}})
-end
-
-When /^I configure the application to use "([^\"]+)" from this project$/ do |name|
- gemspec = File.join(PROJECT_ROOT, "#{name}.gemspec")
- eval("$specification = begin; #{IO.read(gemspec)}; end")
- version = $specification.version
- name = $specification.name
-
- vendor_gem_root = File.join(RAILS_ROOT, 'vendor', 'gems')
- vendor_gem_path = File.join(vendor_gem_root, "shoulda-#{version}")
-
- FileUtils.mkdir_p(vendor_gem_root)
- FileUtils.ln_s(PROJECT_ROOT, vendor_gem_path)
- File.open(File.join(vendor_gem_path, ".specification"), "w") do |file|
- file.write($specification.to_yaml)
- end
-
- insert_into_environment("config.gem '#{name}'")
-end
-
-When /^I configure the application to use rspec\-rails$/ do
- # we have to unpack and copy the generator because Rails won't find the
- # generators if rspec-rails 2 is installed
- insert_into_environment("config.gem 'rspec-rails', :lib => false, :version => '1.2.9'")
- insert_into_environment("config.gem 'rspec', :lib => false, :version => '1.2.9'")
- steps %{
- When I run "rake gems:unpack"
- }
- rspec_generator = File.join(RAILS_ROOT,
- 'vendor',
- 'gems',
- 'rspec-rails-1.2.9',
- 'generators')
- FileUtils.cp_r(rspec_generator, File.join(RAILS_ROOT, 'lib'))
-end
-
-When /^I run the rspec generator$/ do
- steps %{
- When I run the "rspec" generator
- }
-end
-
-When /^I run the "([^"]*)" generator$/ do |name|
- steps %{
- When I run "./script/generate #{name}"
- }
-end
-
-When /^I configure a wildcard route$/ do
- steps %{
- When I save the following as "config/routes.rb"
- """
- ActionController::Routing::Routes.draw do |map|
- map.connect ':controller/:action/:id'
- end
- """
- }
-end
-
-module InsertionHelpers
- def insert_into(path, find, replace)
- contents = IO.read(path)
- contents.sub!(find, replace)
- File.open(path, "w") { |file| file.write(contents) }
- end
-
- def insert_into_environment(contents)
- environment_file = File.join(RAILS_ROOT, 'config', 'environment.rb')
- initializer = "Rails::Initializer.run do |config|"
- replace = "#{initializer}\n #{contents}"
- insert_into(environment_file, initializer, replace)
- end
-end
-
-World(InsertionHelpers)
@@ -13,7 +13,7 @@
When /^I configure the application to use "([^\"]+)" from this project$/ do |name|
append_to_gemfile "gem '#{name}', :path => '../../'"
- steps %{And I run "bundle lock"}
+ steps %{And I run "bundle install"}
end
When /^I run the "([^"]*)" generator$/ do |name|
@@ -30,7 +30,7 @@
When /^I configure the application to use rspec\-rails$/ do
append_to_gemfile "gem 'rspec-rails', '>= 2.0.0.beta.12'"
- steps %{And I run "bundle lock"}
+ steps %{And I run "bundle install"}
end
When /^I configure a wildcard route$/ do
View
@@ -1,8 +1,6 @@
require 'shoulda/version'
if defined?(RSpec)
- require 'shoulda/integrations/rspec2'
-elsif defined?(Spec)
require 'shoulda/integrations/rspec'
else
require 'shoulda/integrations/test_unit'
@@ -1,13 +1,22 @@
require 'shoulda/active_record/matchers'
require 'shoulda/action_controller/matchers'
require 'shoulda/action_mailer/matchers'
-require 'active_support/test_case'
# :enddoc:
-module ActiveSupport
- class TestCase
+
+module RSpec
+ module Matchers
include Shoulda::ActiveRecord::Matchers
- include Shoulda::ActionController::Matchers
- include Shoulda::ActionMailer::Matchers
+ end
+
+ module Rails
+ module ControllerExampleGroup
+ include Shoulda::ActionController::Matchers
+ end
+
+ module MailerExampleGroup
+ include Shoulda::ActionMailer::Matchers
+ end
end
end
+
@@ -1,22 +0,0 @@
-require 'shoulda/active_record/matchers'
-require 'shoulda/action_controller/matchers'
-require 'shoulda/action_mailer/matchers'
-
-# :enddoc:
-
-module RSpec
- module Matchers
- include Shoulda::ActiveRecord::Matchers
- end
-
- module Rails
- module ControllerExampleGroup
- include Shoulda::ActionController::Matchers
- end
-
- module MailerExampleGroup
- include Shoulda::ActionMailer::Matchers
- end
- end
-end
-
@@ -1,130 +0,0 @@
-class ActiveSupport::TestCase
-
- TMP_VIEW_PATH =
- File.expand_path(File.join(File.dirname(__FILE__), 'rails2_root', 'tmp', 'views')).freeze
-
- def create_table(table_name, &block)
- connection = ActiveRecord::Base.connection
-
- begin
- connection.execute("DROP TABLE IF EXISTS #{table_name}")
- connection.create_table(table_name, &block)
- @created_tables ||= []
- @created_tables << table_name
- connection
- rescue Exception => e
- connection.execute("DROP TABLE IF EXISTS #{table_name}")
- raise e
- end
- end
-
- def define_constant(class_name, base, &block)
- class_name = class_name.to_s.camelize
-
- klass = Class.new(base)
- Object.const_set(class_name, klass)
-
- klass.class_eval(&block) if block_given?
-
- @defined_constants ||= []
- @defined_constants << class_name
-
- klass
- end
-
- def define_model_class(class_name, &block)
- define_constant(class_name, ActiveRecord::Base, &block)
- end
-
- def define_model(name, columns = {}, &block)
- class_name = name.to_s.pluralize.classify
- table_name = class_name.tableize
-
- create_table(table_name) do |table|
- columns.each do |name, type|
- table.column name, type
- end
- end
-
- define_model_class(class_name, &block)
- end
-
- def define_mailer(name, paths, &block)
- class_name = name.to_s.pluralize.classify
- klass = define_constant(class_name, ActionMailer::Base, &block)
-
- paths.each {|path| create_view("#{name}/#{path}", "<%= @message %>")}
- klass.template_root = TMP_VIEW_PATH
- end
-
- def define_controller(class_name, &block)
- class_name = class_name.to_s
- class_name << 'Controller' unless class_name =~ /Controller$/
- define_constant(class_name, ActionController::Base, &block)
- end
-
- def define_routes(&block)
- @replaced_routes = ActionController::Routing::Routes
- new_routes = ActionController::Routing::RouteSet.new
- silence_warnings do
- ActionController::Routing.const_set('Routes', new_routes)
- end
- new_routes.draw(&block)
- end
-
- def build_response(opts = {}, &block)
- action = opts[:action] || 'example'
- klass = define_controller('Examples')
- block ||= lambda { render :nothing => true }
- klass.class_eval { define_method(action, &block) }
- define_routes do |map|
- map.connect 'examples', :controller => 'examples', :action => action
- end
-
- create_view("examples/#{action}.html.erb", "abc")
- klass.view_paths = [TMP_VIEW_PATH]
-
- @controller = klass.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- get action
-
- @controller
- end
-
- def create_view(path, contents)
- full_path = File.join(TMP_VIEW_PATH, path)
- FileUtils.mkdir_p(File.dirname(full_path))
- File.open(full_path, 'w') { |file| file.write(contents) }
- end
-
- def teardown_with_models
- if @defined_constants
- @defined_constants.each do |class_name|
- Object.send(:remove_const, class_name)
- end
- end
-
- if @created_tables
- @created_tables.each do |table_name|
- ActiveRecord::Base.
- connection.
- execute("DROP TABLE IF EXISTS #{table_name}")
- end
- end
-
- if @replaced_routes
- ActionController::Routing::Routes.clear!
- silence_warnings do
- ActionController::Routing.const_set('Routes', @replaced_routes)
- end
- @replaced_routes.reload!
- end
-
- FileUtils.rm_rf(TMP_VIEW_PATH)
-
- teardown_without_models
- end
- alias_method :teardown_without_models, :teardown
- alias_method :teardown, :teardown_with_models
-end
Oops, something went wrong.

0 comments on commit a01e60a

Please sign in to comment.