2012-03-01 46 views
12

我不知道爲什麼會這樣突然。我想知道如何解決,請,如果任何人遇到了在此之前或有在哪裏看的想法。使用bundle exec不會修復,具有相同的行爲。耙分貝:測試:準備在Rails 3的應用程序失敗,找不到文件

耙版本0.9.2.2 軌版本3.2.1 rspec的2.8.0版

rake db:test:prepare --trace 
** Invoke db:test:prepare (first_time) 
** Invoke db:abort_if_pending_migrations (first_time) 
** Invoke environment (first_time) 
** Execute environment 
** Execute db:abort_if_pending_migrations 
** Execute db:test:prepare 
** Invoke db:test:load (first_time) 
** Invoke db:test:purge (first_time) 
** Invoke environment 
** Execute db:test:purge 
** Execute db:test:load 
** Invoke db:test:load_schema (first_time) 
** Invoke db:test:purge 
** Execute db:test:load_schema 
** Invoke db:schema:load (first_time) 
** Invoke environment 
** Execute db:schema:load 
/Users/ivan/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:167:in `block in  non_options': file not found: db:test:prepare (ArgumentError) 
from /Users/ivan/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:146:in `map!' 
from /Users/ivan/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:146:in `non_options' 
from /Users/ivan/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:207:in `non_options' 
from /Users/ivan/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:52:in `process_args' 
from /Users/ivan/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/minitest/unit.rb:891:in `_run' 
from /Users/ivan/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/minitest/unit.rb:884:in `run' 
from /Users/ivan/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:21:in `run' 
from /Users/ivan/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:326:in `block (2 levels) in autorun' 
from /Users/ivan/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:27:in `run_once' 
from /Users/ivan/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:325:in `block in autorun' 

,這裏是我的耙-T

→ rake -T 
rake about        # List versions of all Rails frameworks and   the environment 
rake assets:clean      # Remove compiled assets 
rake assets:precompile     # Compile all the assets named in   config.assets.precompile 
rake bourbon:install[sass_path]  # Move files to the Rails assets directory. 
rake clean        # Remove any temporary products. 
rake clobber       # Remove any generated file. 
rake cucumber       # Alias for cucumber:ok 
rake cucumber:all      # Run all features 
rake cucumber:ok      # Run features that should pass 
rake cucumber:rerun     # Record failing features and run only them if any exist 
rake cucumber:wip      # Run features that are being worked on 
rake db:create       # Create the database from config/database.yml for the current Rails.env (use db:crea... 
rake db:database_dump     # Dump the current database to a MySQL file 
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:projects    # Migrates Projects 
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:res... 
rake db:structure:dump     # Dump the database structure to db/structure.sql. Specify another file with DB_STRUC... 
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 (opt... 
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 paperclip:clean     # Cleans out invalid attachments. 
rake paperclip:refresh     # Refreshes both metadata and thumbnails. 
rake paperclip:refresh:metadata  # Regenerates content_type/size metadata for a given CLASS (and optional ATTACHMENT). 
rake paperclip:refresh:missing_styles # Regenerates missing thumbnail styles for all classes using Paperclip. 
rake paperclip:refresh:thumbnails  # Regenerates thumbnails for a given CLASS (and optional ATTACHMENT and STYLES splitt... 
rake rails:template     # Applies the template supplied by LOCATION=(/path/to/template) or URL 
rake rails:update      # Update configs and some other initially generated files (or use just update:configs... 
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 ... 
rake simplecov       # Run tests for simplecov 
rake spec        # Run all specs in spec directory (excluding plugin specs) 
rake spec:controllers     # Run the code examples in spec/controllers 
rake spec:helpers      # Run the code examples in spec/helpers 
rake spec:lib       # Run the code examples in spec/lib 
rake spec:mailers      # Run the code examples in spec/mailers 
rake spec:models      # Run the code examples in spec/models 
rake spec:rcov       # Run all specs with rcov 
rake spec:requests      # Run the code examples in spec/requests 
rake spec:routing      # Run the code examples in spec/routing 
rake spec:views      # Run the code examples in spec/views 
rake stats        # Report code statistics (KLOCs, etc) from the application 
rake test        # Runs test:units, test:functionals, test:integration together (also available: test:... 
rake test:recent      # Run tests for {:recent=>"test:prepare"}/Test recent changes 
rake test:single      # Run tests for {:single=>"test:prepare"} 
rake test:uncommitted     # Run tests for {:uncommitted=>"test:prepare"}/Test changes since last checkin (onl... 
rake time:zones:all     # Displays all time zones, also available: time:zones:us, time:zones:local -- filter ... 
rake tmp:clear       # Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp... 
rake tmp:create      # Creates tmp directories for sessions, cache, sockets, and pids 
Run options: 

# Running tests: 



Finished tests in 0.000395s, 0.0000 tests/s, 0.0000 assertions/s. 

0 tests, 0 assertions, 0 failures, 0 errors, 0 skips 
+0

現在也現在rake db:migrate失敗,出現類似錯誤 – Ivan 2012-03-01 20:58:00

+0

ok,rake db:migrate:status w orks,但最後我仍然遇到類似的錯誤。 – Ivan 2012-03-01 21:07:50

+0

'gem update'固定礦。 – GalacticCowboy 2012-05-11 02:43:41

回答

13

這是發生什麼事的東西(寶石,例如),有一條線,做這樣簡單的東西:

require 'test/unit' 

該文件has an at_exit hook它會自動嘗試運行測試,使用最後在您的命令作爲測試其上運行的名字「這句話」。這就是爲什麼它會報告db:test:prepare無法找到。

例如,shoulda-context寶石這樣做。我們在Spree中使用它,並得到了和你一樣的問題。我開了一個pull request to fix this issue

+0

對不起,今天早上奮力連接點。你最終做了什麼?分叉應該上下文,並要求您的寶石文件中的回購? – Ivan 2012-03-05 18:16:18

+0

我停止使用shoulda-context。 – 2012-03-06 01:24:05

+0

由於shoulda-context目前在gemspec for shoulda中需要,所以我必須分叉shoulda-context並製作上面提到的補丁。如果你知道更好的方法,我很想知道。 – Ivan 2012-03-06 15:09:45

0

也許無用的路徑,但有你最近在開發環境中改變了什麼?像改變XCode?我得到的各種奇怪的東西去,直到我用OSX-GCC-installer的重建。老實說,這看起來像是一個破碎的寶石之外的東西,但我無法解釋我的許多錯誤。

+0

沒有新東西。以防萬一我卸載Xcode和內部崩潰的RVM,重新啓動,安裝了osx-gcc-installer以及1.9.3的新鮮rvm副本,我仍然遇到了錯誤。必須在我的應用程序的某個地方。 – Ivan 2012-03-01 23:37:34

+0

而且,我在Ubuntu上遇到同樣的問題。 – Ivan 2012-03-02 00:38:38

+3

我的天啊,人!你破壞了Ruby! – JohnMetta 2012-03-02 22:01:58

0

我可以再現不同的情況下非常類似的錯誤(外導軌):

  • MRI 1.9.3-P125
  • 瑞克0.9.2
  • Rake文件:Rake::TestTask.new
  • 測試/ test_foo .rb:require "test/unit"

(抱怨測試/測試* .rb未找到,相同堆棧)

解決方法:

鑑於此,也許再看看耙子。特別是如果使用捆綁器,請嘗試bundler exec rake ...而不是rake ...

+0

謝謝,但我確實在使用bundle exec的原始問題中說過沒有區別。你在使用嗎?看Ryan的答案。 – Ivan 2012-03-08 18:21:26

+0

對不起,我錯過了關於bundle exec的說明。 Shoulda沒有被要求重現我的可疑類似的錯誤(只是耙,測試單元和MRI1.9.3-p125)。 我仍然不明白爲什麼,但我不太可能追求這個進一步給予「寶石安裝耙」修復我的東西。祝你好運... – 2012-03-08 22:19:16

0

我能夠通過添加一個 「寶石 '測試單位'」 行,我的Gemfile

3

這爲我解決這個問題:

的Gemfile:

gem 'shoulda-context', require: false 

test_helper.rb中:

require 'shoulda-context' 
相關問題