From dee06f96995e09f2b179a3b9fcd118c96728e769 Mon Sep 17 00:00:00 2001 From: Pat Maddox Date: Wed, 6 Jan 2010 16:28:22 -0800 Subject: [PATCH] multirails & rcov tasks --- .gitignore | 1 + README | 2 + Rakefile | 16 ++++++++ spec/host_app/app/controllers/application.rb | 1 + .../app/controllers/application_controller.rb | 8 ---- spec/host_app/config/environment.rb | 38 +------------------ .../initializers/backtrace_silencers.rb | 7 ---- .../config/initializers/inflections.rb | 10 ----- .../config/initializers/mime_types.rb | 5 --- .../config/initializers/new_rails_defaults.rb | 21 ---------- .../config/initializers/session_store.rb | 15 -------- spec/spec_helper.rb | 3 ++ 12 files changed, 24 insertions(+), 103 deletions(-) create mode 100644 spec/host_app/app/controllers/application.rb delete mode 100644 spec/host_app/config/initializers/backtrace_silencers.rb delete mode 100644 spec/host_app/config/initializers/inflections.rb delete mode 100644 spec/host_app/config/initializers/mime_types.rb delete mode 100644 spec/host_app/config/initializers/new_rails_defaults.rb delete mode 100644 spec/host_app/config/initializers/session_store.rb diff --git a/.gitignore b/.gitignore index d4ecf1f..472d9f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.log pkg +coverage diff --git a/README b/README index 42b738f..72ffd3f 100644 --- a/README +++ b/README @@ -46,6 +46,8 @@ You can spec the Person class in complete isolation. end end +Known to work against Rails versions >= 2.2.2 (run rake:multi_rails:all to test against versions installed on your machine) + Cool people who have contributed to NoPeepingToms: * Brandon Keepers * Corey Haines diff --git a/Rakefile b/Rakefile index 543d3cf..5f10ecd 100644 --- a/Rakefile +++ b/Rakefile @@ -23,3 +23,19 @@ Jeweler::Tasks.new do |s| end Jeweler::GemcutterTasks.new + +require 'spec/rake/spectask' +Spec::Rake::SpecTask.new(:spec) do |spec| + spec.libs << 'lib' << 'spec' + spec.spec_files = FileList['spec/**/*_spec.rb'] +end + +Spec::Rake::SpecTask.new(:rcov) do |spec| + spec.libs << 'lib' << 'spec' + spec.pattern = 'spec/**/*_spec.rb' + spec.rcov = true + spec.rcov_opts = ['--exclude', 'gems/,spec/'] +end + +task :spec => :check_dependencies +task :test => :spec diff --git a/spec/host_app/app/controllers/application.rb b/spec/host_app/app/controllers/application.rb new file mode 100644 index 0000000..3ce96ba --- /dev/null +++ b/spec/host_app/app/controllers/application.rb @@ -0,0 +1 @@ +require 'application_controller' \ No newline at end of file diff --git a/spec/host_app/app/controllers/application_controller.rb b/spec/host_app/app/controllers/application_controller.rb index 6635a3f..09705d1 100644 --- a/spec/host_app/app/controllers/application_controller.rb +++ b/spec/host_app/app/controllers/application_controller.rb @@ -1,10 +1,2 @@ -# Filters added to this controller apply to all controllers in the application. -# Likewise, all the methods added will be available for all controllers. - class ApplicationController < ActionController::Base - helper :all # include all helpers, all the time - protect_from_forgery # See ActionController::RequestForgeryProtection for details - - # Scrub sensitive parameters from your log - # filter_parameter_logging :password end diff --git a/spec/host_app/config/environment.rb b/spec/host_app/config/environment.rb index 029a58b..fb51f50 100644 --- a/spec/host_app/config/environment.rb +++ b/spec/host_app/config/environment.rb @@ -1,41 +1,5 @@ -# Be sure to restart your server when you modify this file - -# Specifies gem version of Rails to use when vendor/rails is not present -RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION - -# Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') Rails::Initializer.run do |config| - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - - # Add additional load paths for your own custom dirs - # config.load_paths += %W( #{RAILS_ROOT}/extras ) - - # Specify gems that this application depends on and have them installed with rake gems:install - # config.gem "bj" - # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net" - # config.gem "sqlite3-ruby", :lib => "sqlite3" - # config.gem "aws-s3", :lib => "aws/s3" - - # Only load the plugins named here, in the order given (default is alphabetical). - # :all can be used as a placeholder for all plugins not explicitly named - # config.plugins = [ :exception_notification, :ssl_requirement, :all ] - - # Skip frameworks you're not going to use. To use Rails without a database, - # you must remove the Active Record framework. - # config.frameworks -= [ :active_record, :active_resource, :action_mailer ] - - # Activate observers that should always be running - # config.active_record.observers = :cacher, :garbage_collector, :forum_observer - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. - config.time_zone = 'UTC' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')] - # config.i18n.default_locale = :de + config.frameworks = [:active_record] end \ No newline at end of file diff --git a/spec/host_app/config/initializers/backtrace_silencers.rb b/spec/host_app/config/initializers/backtrace_silencers.rb deleted file mode 100644 index c2169ed..0000000 --- a/spec/host_app/config/initializers/backtrace_silencers.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. -# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } - -# You can also remove all the silencers if you're trying do debug a problem that might steem from framework code. -# Rails.backtrace_cleaner.remove_silencers! \ No newline at end of file diff --git a/spec/host_app/config/initializers/inflections.rb b/spec/host_app/config/initializers/inflections.rb deleted file mode 100644 index d531b8b..0000000 --- a/spec/host_app/config/initializers/inflections.rb +++ /dev/null @@ -1,10 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new inflection rules using the following format -# (all these examples are active by default): -# ActiveSupport::Inflector.inflections do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' -# inflect.uncountable %w( fish sheep ) -# end diff --git a/spec/host_app/config/initializers/mime_types.rb b/spec/host_app/config/initializers/mime_types.rb deleted file mode 100644 index 72aca7e..0000000 --- a/spec/host_app/config/initializers/mime_types.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new mime types for use in respond_to blocks: -# Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone diff --git a/spec/host_app/config/initializers/new_rails_defaults.rb b/spec/host_app/config/initializers/new_rails_defaults.rb deleted file mode 100644 index c94db0a..0000000 --- a/spec/host_app/config/initializers/new_rails_defaults.rb +++ /dev/null @@ -1,21 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# These settings change the behavior of Rails 2 apps and will be defaults -# for Rails 3. You can remove this initializer when Rails 3 is released. - -if defined?(ActiveRecord) - # Include Active Record class name as root for JSON serialized output. - ActiveRecord::Base.include_root_in_json = true - - # Store the full class name (including module namespace) in STI type column. - ActiveRecord::Base.store_full_sti_class = true -end - -ActionController::Routing.generate_best_match = false - -# Use ISO 8601 format for JSON serialized times and dates. -ActiveSupport.use_standard_json_time_format = true - -# Don't escape HTML entities in JSON, leave that for the #json_escape helper. -# if you're including raw json in an HTML page. -ActiveSupport.escape_html_entities_in_json = false \ No newline at end of file diff --git a/spec/host_app/config/initializers/session_store.rb b/spec/host_app/config/initializers/session_store.rb deleted file mode 100644 index 4f9684a..0000000 --- a/spec/host_app/config/initializers/session_store.rb +++ /dev/null @@ -1,15 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key for verifying cookie session data integrity. -# If you change this key, all old sessions will become invalid! -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -ActionController::Base.session = { - :key => '_host_app_session', - :secret => '0addf6447e1905f8d470d57842d026530ae77f9d9ef94bb93a18f31bb9d61577745b3970e7caf2694ec11d58e41a2448d9ab35d901e55353ce22c0e00dd3a5cd' -} - -# Use the database for sessions instead of the cookie-based default, -# which shouldn't be used to store highly confidential information -# (create the session table with "rake db:sessions:create") -# ActionController::Base.session_store = :active_record_store diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c1f8471..5a2a0a6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,6 @@ +require 'rubygems' +require 'multi_rails' +require 'multi_rails_init' require File.expand_path(File.dirname(__FILE__) + '/host_app/spec/spec_helper') $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') require 'no_peeping_toms'