Wednesday, September 18, 2013

ch 9 cucumber book childprocess gem error

I can't seem to get my final test to pass in chapter 9 in the cucumber book dealing with flickering scenarios. Since I am developing on Windows, it says that I should use the poor man's service manager work around which is using the childprocess gem, and skip the service_manager gem steps. After I do this, the test still do not pass and I'm getting the error:  Unknown error (Windows says "The operation completed successfully.", but it did not.) (ChildProcess::Error). Did anyone find a work around for this error?

Wednesday, September 11, 2013

Ch 2 Cucumber book no such method "success?"

I kept getting this error from section 2.5 in the cucumber book. turns out, for the code @output = `ruby calc.rb #{@input}` you must make sure you are using backticks `  instead of just ticks  ' . I thought it was just the font of the book that made the ticks look different.

Wednesday, November 21, 2012

Installing RADAR on Ubuntu

 DRAFT-DRAFT-DRAFT  Please report any trouble to Prof. Gordon

Assumptions

  1. git client is installed (https://help.ubuntu.com/community/Git)
  2. You have an account with gitorious.org (https://gitorious.org/)
  3. You have created an ssh key and provided your public key to gitorious.org. (https://help.ubuntu.com/community/SSH/OpenSSH/Keys)
  4. You have ruby 1.9.3 and rvm installed.  (http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you)
Preparation

  1. Create a directory into which you want to place your Radar installation. For the sake of this document, we will refer to this directory as $RADAR_HOME
  2. cd $RADAR_HOME. All of the following activity occurs within your current directory as $RADAR_HOME. All file references are relative to $RADAR_HOME.
  3. git clone  git@github.com:rkgordon3/radar.git
  4. sudo apt-get install rake
  5. sudo apt-get install ruby-bundler
  6. bundle install

    If step 7 hangs, comment out the following lines in Gemfile 

    group :test do
            gem 'cucumber-rails', '1.2.1'
            gem 'rspec-rails', '2.7.0'
            gem 'database_cleaner', '0.7.0'
            gem 'factory_girl', '4.1.0'
            gem 'capybara'
    #       gem 'mongoid-rspec', :require => false
    end


    then run bundle install again, then uncomment above lines and run bundle install yet again.

  7. Create a file config/database.yml and put the following in this file:

    development:
       adapter: sqlite3
       database: db/development.sqlite3
       pool: 5
       timeout: 5000

    # Warning: The database defined as "test" will be erased and
    # re-generated from your development database when you run "rake".
    # Do not set this db to the same as development or production.
    test: &test
      adapter: sqlite3
      database: db/test.sqlite3
      pool: 5
      timeout: 5000

    cucumber:
      <<: *test

     
  8. rake db:migrate
  9. rake db:seed
Running Server

You can now run the rails server

rails s

This runs server on port 3000. You can change the port with a -p option.

The seeds file populated the development database with a user 
radar-admin@smumn.edu with password as 'password.' You can log in with that user and then add a couple users for your testing. 

Using Oracle

See this post if you are going to use Oracle database with Radar. In this case, you must also modify config/database.yml. Comment out the current values in the development: group and use these:

adapter: oracle_enhanced
database: ecs4
username:#ask Prof Gordon
password:  #ask Prof Gordon
host: #ask Prof Gordon 

Wednesday, October 24, 2012

Redirection and HTTPS

In reports_controller/search_results, we redirect to reports_controller/index.

If that redirect_to looks like:

redirect_to({ :action => "index",   :div_id => 'results', ... })

it fails because we are running https in production.

To fix this, redirect_to needs a :protocol key in its hash, as below:

redirect_to({ :protocol => "https://" ,
                               :action => "index",
                               :div_id => 'results',


But, that does not work in development mode, so best solution is:

redirect_to({ :protocol => Rails.env.production? 
                             ? "https://"
                             : "http://",
                               :action => "index",
                               :div_id => 'results',









Installing Oracle Instant Client on Ubuntu

The Oracle gem for Rails is ruby-oci8.

To run Radar against Oracle on Ubuntu, you need 'instant client' installed. Directions for this are here.

Radar is currently (as of 10/12) running ruby-oci8 2.0.6 gem. Hence, when installing on Ubuntu, you will run across the following in error log.

  Do you install glibc-devel(redhat) or libc6-dev(debian)?
  You need /usr/include/sys/types.h to compile ruby-oci8.
 
The fix is:

$ sudo ln -s /usr/include/linux/ /usr/include/sys
 
This is described here.

Tuesday, October 23, 2012

Running Script within Radar Environment

You can run a ruby script within rails environment by adding the following two lines to head of script.

require File.join(File.dirname(__FILE__), "..", "config", "boot")
require File.join(File.dirname(__FILE__), "..", "config", "environment")

These two lines setup the rails environment, e.g. ActiveRecord. Your script now has entire Rails/radar set of classes available to it.

The script should be run from application home directory as such:


ruby script/your_script.rb

See script/load_students.rb for an example.

Wednesday, September 26, 2012

Import Students/Drop Students

Currently, updating student database is a manual procedure. It will remain so until we fix index problem in staff_organizations table.

Here are the steps. Replace $RADAR_APP_HOME with root directory of Radar app.

% cd $RADAR_APP_HOME
% cd script
% ftp -s:ftp_cmds
% ruby load_students.rb production
% ruby drop_students.rb production

The file ftp_cmds is not checked into gitorious as it contains passwords. You will have to ask Prof Gordon for it.