Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 'rake test' runs test twice immediately after creating new rails project

Can someone offer troubleshooting tips here?:

With the following sequence of rails related commands:

rails new test6  
bundle install  
rails generate Controller Gohere left right up down
rake test

... seems to run the rake task 'test' twice. Where have I gone wrong?

log is here:

perrys-MacBook-Pro:rails_projects perry_mac$ rails new test6
      create  
      create  README
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/mailers
      create  app/models
      create  app/views/layouts/application.html.erb
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  log
      create  log/server.log
      create  log/production.log
      create  log/development.log
      create  log/test.log
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  public/images
      create  public/images/rails.png
      create  public/stylesheets
      create  public/stylesheets/.gitkeep
      create  public/javascripts
      create  public/javascripts/application.js
      create  public/javascripts/controls.js
      create  public/javascripts/dragdrop.js
      create  public/javascripts/effects.js
      create  public/javascripts/prototype.js
      create  public/javascripts/rails.js
      create  script
      create  script/rails
      create  test
      create  test/fixtures
      create  test/functional
      create  test/integration
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  test/unit
      create  tmp
      create  tmp/sessions
      create  tmp/sockets
      create  tmp/cache
      create  tmp/pids
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
perrys-MacBook-Pro:rails_projects perry_mac$ cd test6
perrys-MacBook-Pro:test6 perry_mac$ bundle install
Fetching source index for http://rubygems.org/
Using rake (0.9.2) 
Using abstract (1.0.0) 
Using activesupport (3.0.9) 
Using builder (2.1.2) 
Using i18n (0.5.0) 
Using activemodel (3.0.9) 
Using erubis (2.6.6) 
Using rack (1.2.3) 
Using rack-mount (0.6.14) 
Using rack-test (0.5.7) 
Using tzinfo (0.3.29) 
Using actionpack (3.0.9) 
Using mime-types (1.16) 
Using polyglot (0.3.1) 
Using treetop (1.4.9) 
Using mail (2.2.19) 
Using actionmailer (3.0.9) 
Using arel (2.0.10) 
Using activerecord (3.0.9) 
Using activeresource (3.0.9) 
Using bundler (1.0.15) 
Using rdoc (3.8) 
Using thor (0.14.6) 
Using railties (3.0.9) 
Using rails (3.0.9) 
Using sqlite3 (1.3.3) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
perrys-MacBook-Pro:test6 perry_mac$ rake test
perrys-MacBook-Pro:test6 perry_mac$ rails generate controller Gohere left right up down
      create  app/controllers/gohere_controller.rb
       route  get "gohere/down"
       route  get "gohere/up"
       route  get "gohere/right"
       route  get "gohere/left"
      invoke  erb
      create    app/views/gohere
      create    app/views/gohere/left.html.erb
      create    app/views/gohere/right.html.erb
      create    app/views/gohere/up.html.erb
      create    app/views/gohere/down.html.erb
      invoke  test_unit
      create    test/functional/gohere_controller_test.rb
      invoke  helper
      create    app/helpers/gohere_helper.rb
      invoke    test_unit
      create      test/unit/helpers/gohere_helper_test.rb
perrys-MacBook-Pro:test6 perry_mac$ rake test                                   Loaded suite /Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/rake_test_loader
Started

Finished in 0.002747 seconds.

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

Test run options: --seed 15229
Loaded suite /Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/rake_test_loader
Started
....
Finished in 0.438403 seconds.

4 tests, 4 assertions, 0 failures, 0 errors, 0 skips

Test run options: --seed 9266
perrys-MacBook-Pro:test6 perry_mac$ 

... and rvm info yields:

perrys-MacBook-Pro:test6 perry_mac$ rvm info

ruby-1.9.2-p290:

  system:
    uname:       "Darwin perrys-MacBook-Pro.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386 i386"
    bash:        "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
    zsh:         "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"

  rvm:
    version:      "rvm 1.6.23 by Wayne E. Seguin ([email protected]) [https://rvm.beginrescueend.com/]"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.2p290"
    date:         "2011-07-09"
    platform:     "x86_64-darwin10.8.0"
    patchlevel:   "2011-07-09 revision 32553"
    full_version: "ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]"

  homes:
    gem:          "/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290"
    ruby:         "/Users/perry_mac/.rvm/rubies/ruby-1.9.2-p290"

  binaries:
    ruby:         "/Users/perry_mac/.rvm/rubies/ruby-1.9.2-p290/bin/ruby"
    irb:          "/Users/perry_mac/.rvm/rubies/ruby-1.9.2-p290/bin/irb"
    gem:          "/Users/perry_mac/.rvm/rubies/ruby-1.9.2-p290/bin/gem"
    rake:         "/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/bin/rake"

  environment:
    PATH:         "/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/bin:/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290@global/bin:/Users/perry_mac/.rvm/rubies/ruby-1.9.2-p290/bin:/Users/perry_mac/.rvm/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin"
    GEM_HOME:     "/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290"
    GEM_PATH:     "/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290:/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290@global"
    MY_RUBY_HOME: "/Users/perry_mac/.rvm/rubies/ruby-1.9.2-p290"
    IRBRC:        "/Users/perry_mac/.rvm/rubies/ruby-1.9.2-p290/.irbrc"
    RUBYOPT:      ""
    gemset:       ""


perrys-MacBook-Pro:test6 perry_mac$ 
like image 598
Perry Horwich Avatar asked Dec 21 '22 11:12

Perry Horwich


1 Answers

I realize this post is pretty old, but in case you never figured it out, or someone else is confused by this (like I was tonight), here's what's going on:

There are actually 2 sets of tests running here: functional tests & unit tests. When you generate a controller in a fresh Rails project like that, you get some functional tests, and you get a stubbed out unit test file with no actual tests in it.

So, the first test results line you see:

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

are the results for the empty unit test file.

As soon as you fill in some unit tests it will show you non-zero results. Note you can also run rake test:units or rake test:functionals to run just one set of tests.

I wish that there was some clearer output to indicate what's going on. It is confusing.

like image 149
Adam Murray Avatar answered Dec 30 '22 07:12

Adam Murray