Test environment

Installation

  1. Add a test database in your database.yml configuration file :
    test:
      adapter: sqlite3
      database: db/test.sqlite3
      pool: 5
      timeout: 5000
    
  2. Create your database with :
     ~foreman$ RAILS_ENV=test rake db:migrate 
  3. Run the all tests :
    ~foreman$ RAILS_ENV=test rake test
  4. Or a singe test :
    ~foreman/test$ RAILS_ENV=test ruby functional/your_test.rb 

Troubleshooting

  • If you have some errors like that :
     /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- rr (MissingSourceFile) 

    juste install missing gem. In that case :
    gem install rr
  • If you get this kind of errors when running functional tests:
    test_should_not_remove_the_anonymous_role(UsersControllerTest):
    ActionController::RoutingError: No route matches {:controller=>"users", :commit=>"Submit", :id=>980190963, :action=>"update", :user=>{:login=>"johnsmith"}}
        test/functional/users_controller_test.rb:32:in `test_should_not_remove_the_anonymous_role'
    

    it means you need to set `:login: true` in the `config/settings.yaml` file.

Also available in: HTML TXT