2012-03-01 8 views
12

Non sono sicuro del motivo per cui tutto questo accade all'improvviso. Mi piacerebbe sapere come risolvere, per favore, se qualcun altro si è imbattuto in questo prima o ha idee su dove cercare. L'uso di bundle exec non risolve, ha lo stesso comportamento.Rake db: test: prepararsi nell'app Rails 3 non riesce con il file non trovato

versione rastrello 0.9.2.2 rotaie versione 3.2.1 versione 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' 

ed ecco il mio rake -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

anche ora rake db: migrate sta fallendo con un errore simile – Ivan

+0

ok, rake db: migrate: stato w ork, ma ho ancora un errore simile alla fine. – Ivan

+0

'gem update 'risolto il mio. – GalacticCowboy

risposta

13

Questo è ciò che accade quando qualcosa (un gioiello, per esempio), ha una linea che fa qualcosa di semplice come questo:

require 'test/unit' 

Questo file has an at_exit hook che tenta automaticamente di eseguire i test, utilizzando l'ultima "frase" nel comando come il nome del test da eseguire. Questo è il motivo per cui non è possibile trovare db:test:prepare.

Ad esempio, la gemma shoulda-context fa questo. Lo stavamo usando in Spree e abbiamo avuto lo stesso problema di te. Ho aperto uno pull request to fix this issue.

+0

Mi dispiace, sto lottando per collegare i puntini stamattina. Cosa hai finito? Forking dovrebbe un contesto e richiede il tuo repo nel tuo Gemfile? – Ivan

+0

Ho smesso di usare shoulda-context. –

+0

Dato che shoulda-context è attualmente richiesto nel gemspec per shoulda, ho dovuto fork shoulda-context e creare la patch suggerita sopra. Se conosci un modo migliore, mi piacerebbe saperlo. – Ivan

0

Forse un percorso non utile, ma hanno hai cambiato qualcosa nel tuo ambiente di sviluppo di recente? Ti piace cambiare XCode? Stavo succedendo un sacco di cose strane fino a quando non sono stato ricostruito con l'osx-gcc-installer.

Onestamente, questo sembra qualcosa al di fuori di una gemma spezzata, ma non ho potuto nemmeno spiegare molti dei miei errori.

+0

Niente di nuovo. Nel caso in cui ho disinstallato Xcode e RVM imploso, riavviato, installato osx-gcc-installer e una nuova copia rvm di 1.9.3 e sto ancora ricevendo l'errore. Deve essere qualcosa nella mia app da qualche parte. – Ivan

+0

E, sto ricevendo lo stesso problema su Ubuntu. – Ivan

+3

Mio Dio, amico! Hai rotto Ruby! – JohnMetta

0

posso riprodurre un errore molto simile in diverse circostanze (rotaie esterne):

  • MRI 1.9.3-p125
  • Rake 0.9.2
  • Rakefile: Rake::TestTask.new
  • test/test_foo .RB: require "test/unit"

(lamenta test/test * .RB non trovato, stesso stack)

Soluzioni alternative:

Dato questo, forse dare una seconda occhiata al rake. In particolare se si utilizza bundler, provare bundler exec rake ... anziché solo rake ...?

+0

Grazie, ma ho detto nella domanda originale che l'uso di bundle exec non ha fatto alcuna differenza. Stai usando shoulda? Vedi la risposta di Ryan. – Ivan

+0

Mi dispiace, ho perso la tua nota sul pacchetto exec. Non è stato richiesto a Shoulda di riprodurre il mio errore sospetto simile come sopra (solo rake, test-unit e MRI1.9.3-p125). Non ho ancora capito perché, ma è improbabile che continui su questo ulteriore dato che "gem install rake" risolve le cose per me. In bocca al lupo... –

0

sono stato in grado di risolvere questo problema con l'aggiunta di una "gemma 'test-unit'" linea al mio Gemfile

3

Questo ha funzionato per me:

Gemfile:

gem 'shoulda-context', require: false 

test_helper.rb :

require 'shoulda-context' 
Problemi correlati