2015-02-23 22 views
13

Sto leggendo il tutorial di Ruby on Rails di Michael Hartl e il seguito. Ho comunque problemi quando provo a fare qualche test.Minitest Issues Ruby on Rails

[[email protected] twitter-clone]$ bundle exec rake test 
/media/Data.II/Dropbox/Web Development/odin-project/3. Ruby on Rails/twitter-clone/db/schema.rb doesn't exist yet. Run `rake db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /media/Data.II/Dropbox/Web Development/odin-project/3. Ruby on Rails/twitter-clone/config/application.rb to limit the frameworks that will be loaded. 
/home/fran/.gem/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- guard (LoadError) 
    from /home/fran/.gem/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require' 
    from /home/fran/.gem/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency' 
    from /home/fran/.gem/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require' 
    from /usr/lib/ruby/gems/2.2.0/gems/guard-minitest-2.4.4/lib/minitest/guard_minitest_plugin.rb:4:in `<top (required)>' 
    from /home/fran/.gem/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require' 
    from /home/fran/.gem/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require' 
    from /home/fran/.gem/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency' 
    from /home/fran/.gem/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require' 
    from /usr/lib/ruby/gems/2.2.0/gems/minitest-5.5.1/lib/minitest.rb:91:in `block in load_plugins' 
    from /usr/lib/ruby/gems/2.2.0/gems/minitest-5.5.1/lib/minitest.rb:85:in `each' 
    from /usr/lib/ruby/gems/2.2.0/gems/minitest-5.5.1/lib/minitest.rb:85:in `load_plugins' 
    from /usr/lib/ruby/gems/2.2.0/gems/minitest-5.5.1/lib/minitest.rb:114:in `run' 
    from /usr/lib/ruby/gems/2.2.0/gems/minitest-5.5.1/lib/minitest.rb:56:in `block in autorun' 

corro rake db:migrate (anche pensato non ho ancora creato nessuna migrazione) e ora l'errore è la seguente:

[[email protected] twitter-clone]$ rake db:migrate 
    (1340.1ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
    (0.1ms) select sqlite_version(*) 
    (143.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version") 
    ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations" 
[[email protected] twitter-clone]$ bundle exec rake test 
    (526.7ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
    (0.2ms) select sqlite_version(*) 
    (243.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version") 
    (0.4ms) SELECT version FROM "schema_migrations" 
    (219.4ms) INSERT INTO "schema_migrations" (version) VALUES ('0') 
    ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations" 
/home/fran/.gem/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- guard (LoadError) 
    from /home/fran/.gem/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require' 
    from /home/fran/.gem/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency' 
    from /home/fran/.gem/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require' 
    from /usr/lib/ruby/gems/2.2.0/gems/guard-minitest-2.4.4/lib/minitest/guard_minitest_plugin.rb:4:in `<top (required)>' 
    from /home/fran/.gem/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require' 
    from /home/fran/.gem/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require' 
    from /home/fran/.gem/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency' 
    from /home/fran/.gem/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require' 
    from /usr/lib/ruby/gems/2.2.0/gems/minitest-5.5.1/lib/minitest.rb:91:in `block in load_plugins' 
    from /usr/lib/ruby/gems/2.2.0/gems/minitest-5.5.1/lib/minitest.rb:85:in `each' 
    from /usr/lib/ruby/gems/2.2.0/gems/minitest-5.5.1/lib/minitest.rb:85:in `load_plugins' 
    from /usr/lib/ruby/gems/2.2.0/gems/minitest-5.5.1/lib/minitest.rb:114:in `run' 
    from /usr/lib/ruby/gems/2.2.0/gems/minitest-5.5.1/lib/minitest.rb:56:in `block in autorun' 

Questo è il mio Gemfile:

source 'https://rubygems.org' 


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 
gem 'rails', '4.2.0' 

# Use SCSS for stylesheets 
gem 'sass-rails', '~> 5.0' 
# Use Uglifier as compressor for JavaScript assets 
gem 'uglifier', '>= 1.3.0' 
# Use CoffeeScript for .coffee assets and views 
gem 'coffee-rails', '~> 4.1.0' 
# See https://github.com/sstephenson/execjs#readme for more supported runtimes 
# gem 'therubyracer', platforms: :ruby 

# Use jquery as the JavaScript library 
gem 'jquery-rails' 
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 
gem 'turbolinks' 
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 
gem 'jbuilder', '~> 2.0' 
# bundle exec rake doc:rails generates the API under doc/api. 
gem 'sdoc', '~> 0.4.0', group: :doc 

# Use ActiveModel has_secure_password 
# gem 'bcrypt', '~> 3.1.7' 

# Use Unicorn as the app server 
# gem 'unicorn' 

# Use Capistrano for deployment 
# gem 'capistrano-rails', group: :development 

group :development, :test do 
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console 
    gem 'byebug' 

    # Access an IRB console on exception pages or by using <%= console %> in views 
    gem 'web-console', '~> 2.0' 

    # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 
    gem 'spring' 

    # Use sqlite3 as the database for Active Record 
    gem 'sqlite3' 

group :test do 
    gem 'minitest-reporters' 
    gem 'mini_backtrace' 
    gem 'guard-minitest' 
end 

group :production do 
    gem 'pg' 
    gem 'rails_12factor' 
end 


end 

Cosa potrebbe essere ? Grazie.

risposta

19

Stai usando il guard-minitest gemma, si prega di vedere la prima linea di the Install section of its README

Vale a dire:

Si prega di essere sicuri di avere Guardia installato prima di continuare.

2

Prova questa, per rimuovere temporaneamente guardia: Modificare la Gemfile e commentare la riga guardia:

# gem 'mini_backtrace' 

Prova questa, per sincronizzare il database di test:

bundle exec rake db:test:prepare 

Prova questa, per verificare che è possibile connettersi al database di sviluppo:

bundle exec rake db 

Prova questa, per verificare che sia possibile connettersi al database di test:

RAILS_ENV=test bundle exec rake db 

Se i passaggi tutti riescono, allora ecco come risolvere il problema di guardia:

group :development, :test do 
    gem 'guard' # NOTE: this is necessary in newer versions 
    gem 'guard-minitest' 
end 

Quindi eseguire:

bundle 
guard init minitest 
+0

Nessuna fortuna. Lo stesso errore continua a scoppiare – FranGoitia

+1

Grazie per il vostro aiuto. Ho risolto aggiungendo gemma "ruby-prof" e "guard" all'ambiente di test nel Gemfile. – FranGoitia