ラベル Ruby の投稿を表示しています。 すべての投稿を表示
ラベル Ruby の投稿を表示しています。 すべての投稿を表示

2009/12/16

Ruby on Rails で RSpec を使うときのメモ

参考

vender/gems にインストールしたいので config/environment.rb に次を書き

  config.gem('rspec', :lib => false)
config.gem('rspec-rails', :lib => false)

次を実行する。

rake gems:unpack:dependencies
rake gems:build
script/generate rspec

ちなみに config.gem の :lib は "Use :lib to specify a different name.", "To require a library be installed, but not attempt to load it, pass :lib => false" -- http://api.rubyonrails.org/classes/Rails/Configuration.html ということらしい。テスト用なら :lib => false にする。

ルートのテスト

ルートのテストでは route_to を使う。

{ :get => '/users' }.should route_to(:controller => 'users', :action => 'index')
{ :get => "/users/1" }.should route_to(:controller => 'users', :action => 'show', :id => '1')
{ :get => "/users/1/edit" }.should route_to(:controller => 'users', :action => 'edit', :id => '1')
{ :put => '/users/1' }.should route_to(:controller => 'users', :action => 'update', :id => '1')
{ :delete => '/users/1' }.should route_to(:controller => 'users', :action => 'destroy', :id => '1')

ビューのテスト

ビューのテストでは assigns[:key] でインスタンス変数を設定する。 flash[:key], params[:key], session[:key] もある。

assigns[:post] = @post = stub_model(Post,
:name => "value for name",
:title => "value for title",
:content => "value for content")

タグは have_tag で。 content_for は response[:capture].should have_tag を使う。

response.should have_tag('p', "名前")

response.should have_tag("form[action=?][method=post]", posts_path) do
with_tag("input#post_name[name=?]", "post[name]")
with_tag("input#post_title[name=?]", "post[title]")
with_tag("textarea#post_content[name=?]", "post[content]")
end

response[:footer].should have_tag(‘div’)

ヘルパーメソッドのモック、スタブは template オブジェクトで。

template.should_receive(:logged_in?).with().and_return(true)
template.should_receive(:current_user).with().and_return(mock(User))

コントローラのテスト

mock_model 使えば DB なしでテストできる。ログイン状態にしたいときなどは controller.stub! を使う。

@user = mock_model(User)
@user.stub!(:user_profile).and_return(@user_profile)
controller.stub!(:current_user).and_return(@user)
get :show, :id => 1
response.should be_success
response.should render_template("user_profiles/show.html.erb")

2009/12/14

capistrano-ext

Ruby on Rails のデプロイに便利な Capistrano のエクステンションらしい。デプロイ環境毎に設定ファイルを分割できる。

参考

インストール。

gem install capistrano-ext

./config/deploy.rb に

require "capistrano/ext/multistage"
を足す。

これで ./config/deploy/ の下に環境毎の設定ファイルを作成できるようになる。

例えば ./config/deploy/staging.rb を作成して、実行するには次のとおり。

cap staging deploy

./config/deploy/aaa.rb を作成して cap -T とすると aaa タスクが追加になっている。

cap aaa                  # Set the target stage to `aaa'.

ここで aaa とか指定せずに cap するとしかられる。

$ cap deploy:check
triggering start callbacks for `deploy:check'
* executing `multistage:ensure'
No stage specified. Please specify one of: aaa (e.g. `cap aaa deploy:check')
なるほど。

Capistrano

Ruby on Rails のデプロイに便利な Capistrano の使用メモ。

参考

インストール。 termios はディスプレイにパスワードが表示されないようにするためにインストールしておく。

gem install capistrano
gem install termios

アプリケーションのルートディレクトリで capify をカレントディレクトリ指定で実行すると、2つのファイルができる。

  • ./Capfile ← 特にいじる必要なし
  • ./config/deploy.rb ← いじるファイル
capify .

./config/deploy.rb に必要な情報を書く。 Passenger の場合は restart で touch tmp/restart.txt する。

# -*- coding: utf-8 -*-
set :application, "BLOG"
set :repository, "/home/ancient/letter/ruby/rails/apps/blog"

set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

role :web, "127.0.0.1" # Your HTTP server, Apache/etc
role :app, "127.0.0.1" # This may be the same as your `Web` server
role :db, "127.0.0.1", :primary => true # This is where Rails migrations will run
#role :db, "your slave db-server here"

set :deploy_to, "/home/ancient/job/actindi/apache/rails-deploy"
set :use_sudo, false

# ログイン先の環境変数を設定する。
default_environment["PATH"] = "${HOME}/letter/ruby/1.8.7/bin:${PATH}"

# ssh でわけわからなくなったら次のコメントを外してみる。
# ssh_options[:verbose] = :debug

# If you are using Passenger mod_rails uncomment this:
# if you're still using the script/reapear helper you will need
# these http://github.com/rails/irs_process_scripts
namespace :deploy do
task :start do end
task :stop do end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end

ローカルで次のコマンドを実行してサーバに必要なディレクトリを作成する。

cap deploy:setup

デプロイする。

cap deploy

マイグレーションもできる。

cap deploy:migrate

なんかまずかったら rollback できる。

cap deploy:rollback

次のコマンドでタスクの一覧が表示される。

cap -T

ssh でわけわからなくなったら次を ./config/deploy.rb に入れてみる。

ssh_options[:verbose] = :debgu

Rails Paperclip

Ruby on Rails の画像アップロードプラグイン(?) Paperclip の使用メモ。

サムネイルつくるのに ImageMagick が必要なので別途インストールしておく。

参考

インストール

script/plugin install git://github.com/thoughtbot/paperclip.git

今回は新規にモデルを作ってみる。 Paperclip は次の4つのカラムを必要とする。

  • avatar_file_name:string
  • avatar_content_type:string
  • avatar_file_size:integer
  • avatar_updated_at:datetime
script/generate rspec_model UserProfile name:string self_introduction:text avatar_file_name:string avatar_content_type:string avatar_file_size:integer avatar_updated_at:datetime user:references
rake db:migrate
rake db:migrate RAILS_ENV=test

User と UserProfile のリレーションを設定。

class User < ActiveRecord::Base
has_one :user_profile
...
end

モデルに has_attached_file(name, options = {}) を追加する。 options には次が指定可能。

  • url ファイルの場所。ディレクトリも URL も指定可能。デフォルトは "/system/:attachment/:id/:style/:filename"
  • default_url 画像がない場合に表示する画像の場所。
  • styles サムネイルの設定ハッシュ。
  • default_style url メソッドで引数を省略した場合の値。 styles ハッシュのキーを指定する。
  • whiny post_process でエラーが発生した場合にエラーをあげるか。デフォルト true
  • convert_options convert コマンドに渡すオプションのハッシュ。キーは styles ハッシュのキー。:all をキーとしたものは全てに適用。 http://www.imagemagick.org/script/convert.php を参照。
  • storage ファイルを保存するストレージ。 :filesystem か :s3。デフォルトは :filesystem。
class UserProfile < ActiveRecord::Base
belongs_to :user
has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
end

UserProfile のコントローラを作成。

script/generate rspec_controller UserProfiles show new edit

config/routes.rb に追加。

  map.resource :user_profile

登録のビュー。 :html => { :multipart => true } が必要。

<h1>ユーザプロフィール作成</h1>
<% form_for@user_profile, :html => { :multipart => true } do |f| %>
<p>
<%= f.label :name %>
<%= f.text_field :name %>
</p>
<p>
<%= f.label :self_introduction %>
<%= f.text_field :self_introduction %>
</p>
<p>
<%= f.label :avatar %>
<%= f.file_field :avatar %>
</p>
<p>
<%= f.submit '保存' %>
</p>
<% end %>

コントローラ。

# -*- coding: utf-8 -*-
class UserProfilesController < ApplicationController
def show
@user = User.find(current_user)
@user_profile = @user.user_profile
end

def new
@user_profile = UserProfile.new
end

def create
@user = User.find(current_user)
@user_profile = UserProfile.create(params[:user_profile])
@user.user_profile = @user_profile
if @user.save
flash[:notice] = 'ユーザプロフィールを作成しました。'
redirect_to @user_profile
else
render :action => :new
end
end
end

2009/12/11

Rails restful-authentication

Ruby on Rails の認証プラグイン restful-authentication を使うメモ。

参考サイト

インストール

script/plugin install git://github.com/technoweenie/restful-authentication.git

ジェネレート。引数は

  • ユーザとかアカウントとか言われるもののモデル
  • セッションコントローラ
  • RSpec のテストを生成
  • アクティベーションを使う
script/generate authenticated user sessions --rspec --include-activation
rake db:migrate
rake db:migrate RAILS_ENV=test

次のコードが config/routes.rb に自動的に追加されている。

map.logout '/logout', :controller => 'sessions', :action => 'destroy'
map.login '/login', :controller => 'sessions', :action => 'new'
map.register '/register', :controller => 'users', :action => 'create'
map.signup '/signup', :controller => 'users', :action => 'new'
map.resources :users
map.resource :session

が、アクティベーションのために

  map.activate '/activate/:activation_code', :controller => 'users', :action => 'activate', :activation_code => nil
も追加する。

users_controller.rb の次の行を application_controller.rb に移動する。

  # Be sure to include AuthenticationSystem in Application Controller instead
include AuthenticatedSystem

ログインが必要なアクションをコントローラで次のように指定する。指定したアクションを実行するとログイン画面に遷移するようになる。

before_filter :login_required, :only => [:new, :edit, :create, :update, :destroy]

アクティベーションメールのために、

config/environment.rb にオブザーバを追加。

  # result-authentication のアクティベーション用オブザーバ
config.active_record.observers = :user_observer

config/environments/development.rb でメールの設定。

config.action_mailer.delivery_method = :sendmail
config.action_mailer.raise_delivery_errors = true

次のファイルでメールの内容等を指定する。

  • app/models/user_mailer.rb
  • app/views/user_mailer/signup_notification.erb
  • app/views/user_mailer/activation.erb

これで http://localhost:3000/signup からサインアップするとメールが送信され、メールのリンクをクリックするとアカウントが使えるようになる。

:セキュリティ上の注意事項 config/initializers/site_keys.rb は秘密にしましょう。

2009/12/10

Rails I18n

参考

i18n 用に、ブランチを作って作業する。

git checkout master
git branch i18n
git checkout i18n

amatsuda's i18n_generators at master - GitHub をインストール。

script/plugin install git://github.com/amatsuda/i18n_generators.git

次で config/environment.rb に config/locales/ja.yml と config/locales/translation_ja.yml が作成される。モデルも適当に翻訳されてる。

script/generate i18n ja

これでエラーメッセージとか日本語化された。

でも、フォームのラベルとか国際化されないと思ったら↓ということらしい。

2009-09-18 - akimatter にあるとおり app/controllers/application_controller.rb にモンキーパッチを追加したらラベルも国際化された。

ネストしたフォームのラベルも OK!

<% @post.tags.build if @post.tags.empty? %>
<% form_for(@post) do |post_form| %>
<%= post_form.error_messages %>

<p>
<%= post_form.label :name %><br />
<%= post_form.text_field :name %>
</p>
<p>
<%= post_form.label :title %><br />
<%= post_form.text_field :title %>
</p>
<p>
<%= post_form.label :content %><br />
<%= post_form.text_area :content %>
</p>
<h2>タグ</h2>
<% post_form.fields_for :tags do |tag_form| %>
<p>
<%= tag_form.label :name %>
<%= tag_form.text_field :name %>
</p>
<% unless tag_form.object.nil? || tag_form.object.new_record? %>
<p>
<%= tag_form.label :_delete %>
<%= tag_form.check_box :_delete %>
</p>
<% end %>
<% end %>
<p>
<%= post_form.submit '保存' %>
</p>
<% end %>

Ruby on Rails で gettext を使う

あとで i18n もやるので、ブランチを作って作業する。

git branch gettext
git checkout gettext

次を参考に

まず必要なものを vendor/gems にインストールするために

rake -T | grep gems

rake gems                                 # List the gems that this rails application depends on
rake gems:build # Build any native extensions for unpacked gems
rake gems:build:force # Force the build of all gems
rake gems:install # Installs all required gems.
rake gems:refresh_specs # Regenerate gem specifications in correct format.
rake gems:unpack # Unpacks all required gems into vendor/gems.
rake gems:unpack:dependencies # Unpacks all required gems and their dependencies into vendor/gems.

config/environments.rb に config.gem "gettext" を追加する。

Rails::Initializer.run do |config|
config.gem 'locale'
config.gem 'locale_rails'
config.gem 'gettext'
config.gem 'gettext_activerecord'
config.gem 'gettext_rails'

次の一連の rake を実行すると vendor/gems の下に gettext が配置される。

rake gems:unpack:dependencies
rake gems:build

ApplicationController に init_gettext "blog" を追加する。

これでサーバを再起動すると検証エラー等が日本語になっている。

apps/blog/vendor/gems/gettext_rails-2.1.0/README.rdoc を参考に lib/tasks/gettext.rake を作成する。

# -*- mode: ruby -*-
require 'rubygems'

namespace :gettext do

desc "Create mo files"
task :makemo do
require 'gettext_rails/tools'
GetText.create_mofiles
end

desc "Update po file"
task :updatepo do
require 'gettext_rails/tools'
# Need to access DB to find Model table/column names.
# Use config/database.yml which is the same style with rails.
GetText.update_pofiles("blog",
Dir.glob("{app,config,components,lib}/**/*.{rb,erb}"),
"blog 1.0.0")
end

end

次で po/blog.pot ファイルを作成する。

rake gettext:updatepo

po/blog.pot を編集。

次で po/ja/blog.po を作成。この手順は最初の1回だけ。 msginit は cp でも ok?

cd po
mkdir ja
msginit -i blog.pot -o ja/blog.po

po/ja/blog.po の msgstr に日本語を書く。

rake gettext:makemo

次で locale/ja/LC_MESSAGES/blog.mo を作成。

rake makemo

サーバを再起動する。

_() を追加したら rake gettext:updatepo する。 po/ja/blog.po を編集したら rake gettext:makemo して、サーバを再起動する。

2009/12/09

Ruby on Rails のメモ

インストール

gem でインストール

gem install rails

MySQL を使うので

gem install mysql

Getting Started with Rails

Getting Started with Rails をやってみる。

アプリケーションの作成。

MySQL を使う。

rails blog -d mysql

これで blog ディレクトリ以下にいっぱいファイルが作成される。

rake -T

で、rake のタスクがいっぱい表示された。

RSpec を使うために

script/plugin install git://github.com/dchelimsky/rspec.git -r 'refs/tags/1.2.9' script/plugin install git://github.com/dchelimsky/rspec-rails.git -r 'refs/tags/1.2.9' script/generate rspec

DB を作成する。

次で blog_development MySQL にデータベースが作成される。 RSpec のために test の方も作る。

rake db:create rake db:create RAILS_ENV=test

Web サーバの実行

script/server

http://localhost:3000/ にアクセスして動いていることを確認。

About your application’s environment をクリックすると各バージョンが表示される。

script/about でも表示される。

RSpec の実行

次でずっと全テストが走るつづける。

autospec

緑は OK 赤は NG。

apps/blog/spec/spec.opts の —format progress を —format specdoc とすると仕様が表示されるようになる。

次で一回だけ全テストが走る。

rake spec

最初のページを作る

home コントローラを作る。inedx アクション付きで。 RSpec のために rspec_controller で。

script/generate rspec_controller home index

app/views/home/index.html.erb を次の内容に編集する。

<h1>Hello, Rails!</h1>
<p>まみむめも♪</p>

http://localhost:3000/home/index にアクセスすると上記内容が表示される。

このページを http://localhost:3000/ で表示するには public/index.html を削除し、config/routes.rb で map.root を指定する。

  map.root :controller => "home"
scaffold を使ってみる

モデル、ビュー、コントロールが一気にできちゃう。これも rspec_scaffold で。

script/generate rspec_scaffold Post name:string title:string content:text rake db:migrate rake db:migrate RAILS_ENV=test

M-x rinari-sql してできたテーブルを確認してみる。

mysql> show tables;
+----------------------------+
| Tables_in_blog_development |
+----------------------------+
| posts |
| schema_migrations |
+----------------------------+
2 rows in set (0.00 sec)

mysql> SHOW FIELDS FROM `posts`;
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(255) | YES | | NULL | |
| title | varchar(255) | YES | | NULL | |
| content | text | YES | | NULL | |
| created_at | datetime | YES | | NULL | |
| updated_at | datetime | YES | | NULL | |
+------------+--------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)

id, created_at, updated_at はデフォルトで存在するらしい。

app/views/home/index.html.erb にポストページへのリンクを追加する。

<h1>Hello, Rails!</h1>
<p>まみむめも♪</p>
<%= link_to "ブログへ", posts_path %>

posts_path は config/routes.rb に次の行が script/generate scaffold によって追加されて使えるようになっている。レストフルなフレーバー?

map.resources :posts

追加したリンクをクリックすると posts の CRUD ができるようになっている。

autospec が赤になっているので、テストのためのテスト的に spec/views/home/index.html.erb_spec.rb を修正する。 11行目。「まみむめも♪」と書かれた p タグがあることを期待している。

    response.should have_tag('p', %r[まみむめも♪])
validation を追加する

Post に次の validation を追加する。

  • name は必須
  • title は必須
  • title は5文字以上

app/models/post.rb をいじる。

class Post < ActiveRecord::Base
validates_presence_of :name, :title
validates_length_of :title, :minimum => 5
end

RSpec も。

# -*- coding: utf-8 -*-
require 'spec_helper'

describe Post do
before(:each) do
@valid_attributes = {
:name => "value for name",
:title => "value for title",
:content => "value for content"
}
end

it "should create a new instance given valid attributes" do
Post.create!(@valid_attributes)
end

it "name がないと不正" do
post = Post.create(@valid_attributes)
post.name = nil
post.save
post.should_not be_valid
end

it "title がないと不正" do
post = Post.create(@valid_attributes)
post.title = nil
post.save
post.should_not be_valid
end

it "title が4文字だと不正" do
post = Post.create(@valid_attributes)
post.title = "あいうえ"
post.save
post.should_not be_valid
end

it "title が5文字だと正常" do
post = Post.create(@valid_attributes)
post.title = "あいうえお"
post.save
post.should be_valid
end

it "title が6文字でも正常" do
post = Post.create(@valid_attributes)
post.title = "あいうえおか"
post.save
post.should be_valid
end
end
パーシャルテンプレート

app/views/posts/new.html.erb と app/views/posts/edit.html.erb の共通部分をパーシャルテンプレートにする。

共通部分を選択して M-x rinari-extract-partial とすると、名前をきいてくるので form と入力する。 _form.html.erb が作成され、new.html.erb と edit.html.erb は次のようにに編集する。

<%= render :partial => 'form' %>
コメントできるようにする

ポストに対してコメントできるようにする。 rspec_model で Comment モデルを作成。

script/generate rspec_model Comment commenter:string body:text post:references
rake db:migrate
rake db:migrate RAILS_ENV=test

Post は Comment をいくつか持っている。has_many で指定。

class Post < ActiveRecord::Base
validates_presence_of :name, :title
validates_length_of :title, :minimum => 5

has_many :comments
end

config/routes.rb でネスト。

map.resources :posts, :has_many => :comments

rspec_controller で Comment のコントローラを作る。ビューのあるアクションのみ引数に指定する。

script/generate rspec_controller Comments index show new edit

できた app/controllers/CommentsController の中身を実装する。

view を編集(コピペ)。

app/views/posts/show.html.erb にコメントへのリンクを追加。

<%= link_to 'Back', post_comments_path(@post) %>
Building a Multi-Model Form

複数のモデルを扱うフォーム。タグを付けられるようにする。

script/generate rspec_model tag name:string post:references
rake db:migrate
rake db:migrate RAILS_ENV=test

Post モデルを修正。

# -*- coding: utf-8 -*-
class Post < ActiveRecord::Base
validates_presence_of :name, :title
validates_length_of :title, :minimum => 5

has_many :comments

has_many :tags
accepts_nested_attributes_for(:tags,
# 削除チェックボックスのために
:allow_destroy => :true,
:reject_if => proc { |attrs|
# すべての属性が必須
attrs.all? { |k, v|
v.blank?
}
})
end

apps/blog/app/views/posts/_form.html.erb を修正。 new のときのために1行目に ... build if ... を追加。 <% post_form.fields_for :tags do |tag_form| %> を追加。

<% @post.tags.build if @post.tags.empty? %>
<% form_for(@post) do |post_form| %>
<%= post_form.error_messages %>

<p>
<%= post_form.label :name %><br />
<%= post_form.text_field :name %>
</p>
<p>
<%= post_form.label :title %><br />
<%= post_form.text_field :title %>
</p>
<p>
<%= post_form.label :content %><br />
<%= post_form.text_area :content %>
</p>
<h2>タグ</h2>
<% post_form.fields_for :tags do |tag_form| %>
<p>
<%= tag_form.label :name, 'タグ:' %>
<%= tag_form.text_field :name %>
</p>
<% unless tag_form.object.nil? || tag_form.object.new_record? %>
<p>
<%= tag_form.label :_delete %>
<%= tag_form.check_box :_delete %>
</p>
<% end %>
<% end %>
<p>
<%= post_form.submit '保存' %>
</p>
<% end %>

テスト

RSpec でのテスト

ビューのテスト

mock_model でモデルを作って assigns でビューから見えるようにする、ということだろうか。

spec/views/comments/index.html.erb_spec.rb

# -*- coding: utf-8 -*-
require 'spec_helper'

describe "/comments/index" do
before(:each) do
@comment = mock_model(Comment,
:commenter => '田中京子',
:body => '寒かったですね。')
@post = mock_model(Post,
:name => '山田太郎',
:title => '今日のできごと',
:content => '今日はくもりでした。')
assigns[:post] = @post
assigns[:comments] = [@comment]
render 'comments/index'
end

#Delete this example and add some real ones or delete this file
it "should tell you where to find the file" do
response.should have_tag('td', @comment.commenter)
response.should have_tag('td', @comment.body)
end
end

spec/views/comments/show.html.erb_spec.rb

# -*- coding: utf-8 -*-
require 'spec_helper'

describe "/comments/show" do
before(:each) do
@comment = mock_model(Comment,
:commenter => '田中京子',
:body => '寒かったですね。')
@post = mock_model(Post,
:name => '山田太郎',
:title => '今日のできごと',
:content => '今日はくもりでした。',
:comments => [@comment])
assigns[:post] = @post
assigns[:comment] = @comment
render 'comments/show'
end

#Delete this example and add some real ones or delete this file
it "should tell you where to find the file" do
response.should have_tag('p', "#{@comment.commenter} さんのコメント")
response.should have_tag('p', @comment.body)
end
end

spec/views/comments/edit.html.erb_spec.rb

# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
require 'spec_helper'

describe "/comments/edit" do
before(:each) do
@comment = mock_model(Comment,
:commenter => '田中京子',
:body => '寒かったですね。')
@post = mock_model(Post,
:comments => [@comment])
assigns[:post] = @post
assigns[:comment] = @comment
render 'comments/edit'
end

#Delete this example and add some real ones or delete this file
it "should tell you where to find the file" do
response.should have_tag('input[id=comment_commenter][value=?]',
@comment.commenter)
response.should have_tag('textarea[id=comment_body]',
@comment.body)
end
end
モデルのテスト

自動的に作られた comments_controller_spec.rb のテストが失敗するので、 before(:each) でモックを仕込む。

  before(:each) do
@mock_comment = mock_model(Comment, :name => '田中京子',
:body => 'あ')
@mock_post = mock_model(Post,
:name => '山田太郎',
:comments => [@mock_comment])
@mock_post.comments.stub!(:build).and_return(Comment.new)
Post.stub!(:find).and_return(@mock_post)
end

2009/12/07

こういう情報がほしかった

irb を快適に使うための Tips - まさにっき(コードで世界を変えたい人の記録)

gem install wirble して ~/.irbrc に

# -*- coding: utf-8 -*-
#require 'irb/completion'
require 'pp'
require 'rubygems'
require 'wirble'

# 沢山記憶するよ
IRB.conf[:SAVE_HISTORY] = 100000

Wirble.init
Wirble.colorize

素晴らしい。ありがとうございます。

rspec-rails のインストール

リポジトリがどこにあるか探すのに手間取った。 Rails - rspec - GitHub

どんどん GitHub に集まってるのね。

script/plugin install git://github.com/dchelimsky/rspec.git -r 'refs/tags/1.2.9'
script/plugin install git://github.com/dchelimsky/rspec-rails.git -r 'refs/tags/1.2.9'
script/generate rspec