[Ruby on Rails] uninitialized constant ActiveSupport::~::ForRspec
Today I got an error below with rake. What happened? % rake -T (in /home/ice/messa/hulor) rake aborted! uninitialized constant ActiveSupport::Testing::SetupAndTeardown::ForRspec /home/ice/messa/hulor/Rakefile:12 (See full trace by running task with --trace) Related gem packages version: rails 2.3.2 rspec 1.2.4 rspec-rails 1.2.4 I can’t remember what I did. But maybe I installed rails into my project (not on system). I did below???? I can’t remember. % rake rails:freeze:edge #801 ‘No such file to load’ when running ‘rake spec’ Sounds like you’ve got rails edge, not rails-2.3.2. These files moved post-2.3.2 – same with ForRspec – that’s all in rails edge, which is now moving towards rails-3.0, and...
[Ruby] How to use RSpec – 01 QuickStart
RSpec is one of ruby’s testing frameworks for BDD(Behavior Driven Development). Install RSpec % sudo gem install rspec Quickstart Directory Structure for sample program below. put libraries into lib/ directory. put spec(test) programs into spec/directory. sample_project/ lib/sample.rb sample library to test spec/ sample_spec.rb test program for sample.rb spec_helper.rb common settings and functions for all tests. Create directories Create a project directory, create lib and spec directory in the project directory. % mkdir sample_project % cd sample_project % mkdir lib % mkdir spec Create spec_helper.rb sample_project/spec/spec_helper.rb : # encoding: utf-8 require "rubygems" require 'test/unit' require "spec" $LOAD_PATH <<...
[Ruby] HOW TO use multiple databases with ActiveRecord
Sometimes you need to access multiple databases in one application. For example, using different application’s database. But usually ActiveRecord is configured to ActiveRecord::Base directly, and so establishes a connection with ActiveRecord::Base, so you can’t use multiple database with AR. So how to do it? Just create sub-classes of ActiveRecord::Base. Sub-classes of ActiveRecord::Base can access parent class configurations and connections. So create a sub-class of ActiveRecord::Base BaseDB then set configurations to it. Create sub-classes of BaseDB then establish database connection each of them. It’s better than to set configurations and establish connection on ActiveRecord::Base directly for future. ActiveRecord::Base BaseDB <...
Together or alone?
I have started to learning Ruby together with Ian of the messaliberty team. Even though I started off as a programmer and wanted to learn ruby, I feel I wouldn’t have got started by myself. It is due to Ian’s words “Learn together with…” that I finally made the first step. Power of the words “Together with” is great. I don’t know why, but those words have great appeal, especially for us Japanese. If I was alone, I doubt whether I could keep going. But to start off, I felt it was best to start by myself at my own pace. (The learning ruby site’s text is in English. Sometimes I feel lost because of my poor english skills.) But learning programming is fun. As I mentioned I originally hoped to be a...
[Ruby] ActiveRecord off Rails
How to use ActiveRecord without Rails. Memo Usually no need to write definition of database tables. Just define sub class of ActiveRecord::Base. ActiveRecord automatically checks table definition at the first access. Better to use ActiveRecord’s naming rules If name tables or fields without the naming rules, should add extra code into sub class of ActiveRecord::Base Need to write SQL directory when do complicated stuff. Access to table with sub class instance of ActiveRecord::Base Basic Usage Create database configuration YAML file Create a sub class of ActiveRecord::Base for each table Establish connection with the YAML file. Do something with the sub class of ActiveRecord::Base Simple Usage #!/usr/bin/env ruby # definition of 'groups' table #CREATE...

