- ##spec_helper.rb
- require 'rubygems'
- require 'spork'
- Spork.prefork do
- # Loading more in this block will cause your tests to run faster. However,
- # if you change any configuration or code from libraries loaded here, you'll
- # need to restart spork for it take effect.
- # This file is copied to ~/spec when you run 'ruby script/generate rspec'
- # from the project root directory.
- ENV["RAILS_ENV"] = 'test'
- require File.dirname(__FILE__) + "/../config/environment"
- #require 'rspec'#MXDEBUG: WHYYY
- require 'rspec/rails'
- # Unfortunately this incurs a warning that requiring the 'spec' module is deprecated.
- require 'rspec/rr'
- require 'factory_girl_rails'
- require 'database_cleaner'
- DatabaseCleaner.orm = 'mongo_mapper'
- DatabaseCleaner.strategy = :truncation
- Rspec.configure do |config|
- config.mock_with :rr
- config.after do
- DatabaseCleaner.clean
- end
- end
- Dir["#{File.dirname(__FILE__)}/shared/**/*.rb"].each {|f| require f}
- end
- Spork.each_run do
- DatabaseCleaner.clean
- #Dir["#{File.dirname(__FILE__)}/shared/**/*.rb"].each {|f| require f}
- end
- ## lib/tasks/rspec.rake
- begin
- require 'rspec/core'
- require 'rspec/core/rake_task'
- rescue MissingSourceFile
- module RSpec
- module Core
- class RakeTask
- def initialize(name)
- task name do
- # if rspec-rails is a configured gem, this will output helpful material and exit ...
- require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
- # ... otherwise, do this:
- raise <<-MSG
- #{"*" * 80}
- * You are trying to run an rspec rake task defined in
- * #{__FILE__},
- * but rspec can not be found in vendor/gems, vendor/plugins or system gems.
- #{"*" * 80}
- MSG
- end
- end
- end
- end
- end
- end
- Rake.application.instance_variable_get('@tasks').delete('default')
- spec_prereq = Rails.root.join('config', 'database.yml').exist? ? "db:test:prepare" : :noop
- task :noop do
- end
- task :default => :spec
- task :stats => "spec:statsetup"
- desc "Run all specs in spec directory (excluding plugin specs)"
- RSpec::Core::RakeTask.new(:spec => spec_prereq)
- namespace :spec do
- [:requests, :models, :controllers, :views, :helpers, :mailers, :lib].each do |sub|
- desc "Run the code examples in spec/#{sub}"
- RSpec::Core::RakeTask.new(sub => spec_prereq) do |t|
- t.pattern = "./spec/#{sub}/**/*_spec.rb"
- end
- end
- task :statsetup do
- require 'rails/code_statistics'
- ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
- ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
- ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
- ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
- ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
- ::STATS_DIRECTORIES << %w(Mailer\ specs spec/mailers) if File.exist?('spec/mailers')
- ::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing')
- ::STATS_DIRECTORIES << %w(Request\ specs spec/requests) if File.exist?('spec/requests')
- ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
- ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
- ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
- ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
- ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
- ::CodeStatistics::TEST_TYPES << "Mailer specs" if File.exist?('spec/mailer')
- ::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing')
- ::CodeStatistics::TEST_TYPES << "Request specs" if File.exist?('spec/requests')
- end
- end
- ##console
- rake spec
- (in /home/michael/Scripts/CrystalCommerce/CrystalMetrics)
- DEPRECATION WARNING: Rake tasks in /home/michael/Scripts/CrystalCommerce/CrystalMetrics/vendor/plugins/rspec-rr/tasks/rspec_rr_tasks.rake are deprecated. Use lib/tasks instead. (called from load_deprecated_tasks at /home/michael/.rvm/gems/ruby-1.8.7-p249@global/gems/railties-3.0.0.beta4/lib/rails/plugin.rb:50)
- ./spec/shared/contextual_spec.rb:1: undefined method `shared_examples_for' for main:Object (NoMethodError)
- rake aborted!
- bundle exec /home/michael/.rvm/rubies/ruby-1.8.7-p249/bin/ruby -Ilib -Ispec "./spec/shared/contextual_spec.rb" "./spec/shared/json_controller_spec.rb" "./spec/shared/legacy_model_spec.rb" "./spec/controllers/products_controller_spec.rb" "./spec/controllers/clients_controller_spec.rb" "./spec/models/hive/client_spec.rb" "./spec/models/hive/product_spec.rb" "./spec/models/series_spec.rb" "./spec/models/client_spec.rb" "./spec/models/admin/line_item_spec.rb" "./spec/models/admin/variant_spec.rb" "./spec/models/admin/product_spec.rb" "./spec/models/admin/order_spec.rb" "./spec/models/product_spec.rb" "./spec/models/price_spec.rb" "./spec/support/stat_craft_spec.rb" "./spec/support/contextual_spec.rb" "./spec/support/mongo_decimal_spec.rb" failed
- (See full trace by running task with --trace)