简体   繁体   English

运行rake任务时测试单元错误

[英]Test Unit error when running rake tasks

I upgrade my app from rails2 to rails3. 我将我的应用程序从rails2升级到rails3。 Now every time I run a task I get this error: 现在,每次运行任务时,都会出现此错误:

➜  cimm git:(master) ✗ ruby -v
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin13.0.0]
➜  cimm git:(master) ✗ rails -v
Rails 3.0.20
➜  cimm git:(master) ✗ bundle exec rake sitemaps:servicos --trace
** Invoke sitemaps:servicos (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute sitemaps:servicos
/Users/netto/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/test/unit.rb:167:in `block in non_options': file not found: sitemaps:servicos (ArgumentError)
    from /Users/netto/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/test/unit.rb:146:in `map!'
    from /Users/netto/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/test/unit.rb:146:in `non_options'
    from /Users/netto/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/test/unit.rb:207:in `non_options'
    from /Users/netto/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/test/unit.rb:52:in `process_args'
    from /Users/netto/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/minitest/unit.rb:891:in `_run'
    from /Users/netto/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/minitest/unit.rb:884:in `run'
    from /Users/netto/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/test/unit.rb:21:in `run'
    from /Users/netto/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/test/unit.rb:326:in `block (2 levels) in autorun'
    from /Users/netto/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/test/unit.rb:27:in `run_once'
    from /Users/netto/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/test/unit.rb:325:in `block in autorun'

I don't know why is loading something about Test Unit if I'm using Rspec. 如果使用Rspec,我不知道为什么要加载有关Test Unit的信息。 I tried change rake version, changing the require 'rails/all' but none fixed this issue. 我试过更改rake版本,更改了require'rails / all',但没有一个解决此问题。

But my tasks are loaded, so seems this is kind of a warning. 但是我的任务已加载,因此这似乎是一个警告。 But I'd to know how to fix this. 但是我想知道如何解决这个问题。

Update 1 更新1

These errors only appear when my task interact with Model/Controllers. 这些错误仅在我的任务与模型/控制器交互时出现。

My Rakefile: 我的Rakefile:

require File.expand_path('../config/application', __FILE__)
require 'rake'

CIMM::Application.load_tasks

Check your Rakefile. 检查您的Rakefile。 it probably loading TestUnit 它可能正在加载TestUnit

You should show the custom task if you want more help. 如果需要更多帮助,应显示自定义任务。

➜  cimm git:(master) ✗ rake -T
rake about                                    # List versions of all Rails frameworks and the environment
rake airbrake:deploy                          # Notify Airbrake of a new deploy.
rake airbrake:heroku:add_deploy_notification  # Install Heroku deploy notifications addon
rake airbrake:test                            # Verify your gem installation by sending a test exception to the airbrake service / Verify your gem instal...
rake db:create                                # Create the database from config/database.yml for the current Rails.env (use db:create:all to create all d...
rake db:drop                                  # Drops the database for the current Rails.env (use db:drop:all to drop all databases)
rake db:fixtures:load                         # Load fixtures into the current environment's database.
rake db:migrate                               # Migrate the database (options: VERSION=x, VERBOSE=false).
rake db:migrate:status                        # Display status of migrations
rake db:rollback                              # Rolls the schema back to the previous version (specify steps w/ STEP=n).
rake db:schema:dump                           # Create a db/schema.rb file that can be portably used against any DB supported by AR
rake db:schema:load                           # Load a schema.rb file into the database
rake db:seed                                  # Load the seed data from db/seeds.rb
rake db:setup                                 # Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db...
rake db:structure:dump                        # Dump the database structure to an SQL file
rake db:version                               # Retrieves the current schema version number
rake doc:app                                  # Generate docs for the app -- also available doc:rails, doc:guides, doc:plugins (options: TEMPLATE=/rdoc-t...
rake log:clear                                # Truncates all *.log files in log/ to zero bytes
rake middleware                               # Prints out your Rack middleware stack
rake notes                                    # Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)
rake notes:custom                             # Enumerate a custom annotation, specify with ANNOTATION=CUSTOM
rake rails:template                           # Applies the template supplied by LOCATION=(/path/to/template) or URL
rake rails:update                             # Update both configs and public/javascripts from Rails (or use just update:javascripts or update:configs)
rake rails:upgrade:backup                     # Backs up your likely modified files so you can run the Rails 3 generator on your app with little risk
rake rails:upgrade:check                      # Runs a battery of checks on your Rails 2.x app and generates a report on required upgrades for Rails 3
rake rails:upgrade:configuration              # Extracts your configuration code so you can create a new config/application.rb
rake rails:upgrade:gems                       # Generates a Gemfile for your Rails 3 app out of your config.gem directives
rake rails:upgrade:routes                     # Create a new, upgraded route file from your current routes.rb
rake routes                                   # Print out all defined routes in match order, with names.
rake secret                                   # Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie se...
rake sitemaps:servicos                        # Cria sitemap para servicos
rake spec                                     # Run all specs in spec directory (excluding plugin specs)
rake spec:controllers                         # Run the code examples in spec/controllers
rake stats                                    # Report code statistics (KLOCs, etc) from the application
rake time:zones:all                           # Displays all time zones, also available: time:zones:us, time:zones:local -- filter with OFFSET parameter,...
rake tire:import                              # Import data from your model using paginate: rake environment tire:import CLASS='MyModel'.
rake tire:index:drop                          # Delete indices passed in the INDEX environment variable; separate multiple indices by comma.
rake tmp:clear                                # Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sock...
rake tmp:create                               # Creates tmp directories for sessions, cache, sockets, and pids

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM