トップ «前の日記(2011/06/07 (火) ) 最新 次の日記(2011/06/09 (木) )» 編集 RSS feed

HsbtDiary


2011/06/08 (水) [長年日記]

[Rails] Crafting Rails Application 読書会4回目

今日は2章を読み始めた。2章はメールフォームを作って、ActiveModelとValidatorについて勉強するぞーという章。

  • attribute_method_prefix や attribute_method_suffix を使って reset_attribute! みたいなメソッドを作る方法について学ぶぞー
  • ActiveModel に準拠しているかどうかは ActiveModel::Lint:: Tests を include したテストが全部通れば判定できるぞー
  • ActiveModel::Name を extend する @model.class.model_name.human みたいのが使えるようになるぞー

こんなところ。来週は引き続き ActiveModel を作る方法について進める予定。

[omniauth][rack][ruby][rails] omniauth でテストする

omniauth でテストをする方法は github の wiki に書いてある通りに spec_helper.rb あたりに

OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:twitter, {:uid => '12345'})

とでも追記して /auth/twitter にアクセスするとコールバックとして {provider: twitter, uid: 12345} みたいのが帰ってくる。後はこれで認証を通る/通らないような User モデルなり Authentication モデルを fixture で用意すればいい。omniauth はホント便利だなあ。