Project

General

Profile

Test environment » History » Version 7

« Previous - Version 7/9 (diff) - Next » - Current version
Tommy McNeely, 11/18/2015 06:03 PM


Test environment

Prerequisites

  1. Install PhantomJS - http://phantomjs.org/download.html
    The directions below are to install the binary version of PhantomJS 1.9.8 into `/usr/local/bin`, which requires sudo/root access. If you want to install it locally, that should work as well.
      curl -LO https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
      sudo tar xf  phantomjs-1.9.8-linux-x86_64.tar.bz2 -C /usr/local
      sudo ln -sf /usr/local/phantomjs-1.9.8-linux-x86_64/bin/phantomjs /usr/local/bin/
    
  2. PhantomJS also requires fontconfig and freetype
     yum -y install fontconfig  freetype
    

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 -I . 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.
  • If you get errors related to `LocationsController` or `OrganizationsController` when running functional tests it means you need to set `:locations_enabled: true` and `:organizations_enabled: true`. Example errors:
    Api::V2::LocationsControllerTest#test_0001_should get index:
    ActionController::RoutingError: No route matches {:controller=>"api/v2/locations"}
    

    OrganizationsControllerTest#test_0001_should get index:
    ActionController::RoutingError: No route matches {:controller=>"organizations"}
    

    LocationTest#test_0001_index page:
    NameError: undefined local variable or method `locations_path' for #<LocationTest:0x0000000b399030>
    

    OrganizationTest#test_0001_index page:
    NameError: undefined local variable or method `organizations_path' for #<OrganizationTest:0x0000000f6350d8>