履歴: ソフトウェア/rails/ActiveSupport_TestCase + shoulda によるテスト
各行は、その日時に書かれた内容です。追加・削除は、1 つ前の版との行数の差です (全 13 版)。「差分」は比較する版、「基準」は比べる相手の版を選びます
| 日時 | タイトル | 文字数 | 追加 | 削除 | 内容 | 差分 | 基準 |
|---|---|---|---|---|---|---|---|
| 2014/6/2 9:53:59 | ソフトウェア/rails/ActiveSupport_TestCase + shoulda によるテスト 最新版 | 39,445 | +1 | -1 | 表示 | 差分 | — |
| 2014/6/2 9:53:59 | ソフトウェア/rails/ActiveSupport_TestCase + shoulda によるテスト | 39,451 | +6 | -1 | 表示 | 差分 | 選択 |
| 2014/5/30 14:33:33 | ソフトウェア/rails/ActiveSupport_TestCase + shoulda によるテスト | 39,363 | +2 | -0 | 表示 | 差分 | 選択 |
| 2014/5/30 14:32:24 | ソフトウェア/rails/ActiveSupport_TestCase + shoulda によるテスト | 39,288 | +116 | -17 | 表示 | 差分 | 選択 |
| 2014/5/30 7:58:45 | ソフトウェア/rails/ActiveSupport_TestCase + shoulda によるテスト | 36,014 | +229 | -0 | 表示 | 差分 | 選択 |
| 2014/5/26 4:31:48 | ソフトウェア/rails/ActiveSupport_TestCase + shoulda によるテスト | 29,846 | +11 | -4 | 表示 | 表示中 | 選択 |
| 2014/5/26 4:31:48 | ソフトウェア/rails/ActiveSupport_TestCase + shoulda によるテスト | 29,608 | +30 | -0 | 表示 | 差分 | 選択 |
| 2014/5/24 1:25:48 | ソフトウェア/rails/ActiveSupport_TestCase + shoulda によるテスト | 28,564 | +1 | -1 | 表示 | 差分 | 基準 |
| 2014/5/23 17:42:25 | ソフトウェア/rails/ActiveSupport_TestCase + shoulda によるテスト | 27,825 | +163 | -0 | 表示 | 差分 | 選択 |
| 2014/5/23 13:25:19 | ソフトウェア/rails/ActiveSupport_TestCase + shoulda によるテスト | 21,221 | +174 | -2 | 表示 | 差分 | 選択 |
| 2014/5/23 3:13:32 | ソフトウェア/rails/ActiveSupport_TestCase + shoulda によるテスト | 15,654 | +253 | -88 | 表示 | 差分 | 選択 |
| 2014/5/22 14:25:52 | ソフトウェア/rails/ActiveSupport_TestCase + shoulda によるテスト | 12,435 | +167 | -47 | 表示 | 差分 | 選択 |
| 2014/5/22 13:28:26 | ソフトウェア/rails/ActiveSupport_TestCase + shoulda によるテスト | 9,057 | — | — | 表示 | — | 選択 |
基準: ソフトウェア/rails/ActiveSupport_TestCase + shoulda によるテスト (2014/5/24 1:25:48) → 比較: ソフトウェア/rails/ActiveSupport_TestCase + shoulda によるテスト (2014/5/26 4:31:48)
@@ -447,7 +447,7 @@
** I18n.translate の翻訳の抜けを検出する [#ub2cc8f0]
-config/initializers/test_i18n_translation_strictly.rb
+test/test_i18n_translation_strictly.rb
LANG:ruby(linenumber)
# coding: utf-8
@@ -836,6 +836,8 @@
* shouda の matcher [#gd8d5b05]
+** 一覧 [#m5e4b4ec]
+
#multicolumns
*** [[ActiveModel Matchers>https://github.com/thoughtbot/shoulda-matchers#activemodel-matchers]] [#n7a5004d]
@@ -897,17 +899,52 @@
ActionModel の
-allow_value
+-- allow_value('http://foo.com', 'http://bar.com/baz').for(:website_url)
+-- allow_value('2013-01-01').for(:birthday_as_string).on(:create)
+-- allow_value('open', 'closed').for(:state).with_message('State must be open or closed')
ActionController の
-redirect_to
+-- redirect_to :list
+-- redirect_to("description") { posts_path }
-render_template
+-- render_template 'show'
+-- render_template :show
-respond_with
+-- respond_with 403
+-- respond_with :success
+-- respond_with 500..600
+-route
+-- route(:get, '/posts').to(controller: 'posts', action: 'index')
+-- route(:get, '/posts/1').to('posts#show', id: 1)
-set_session
+-- set_session :key
+-- set_session(:key).to("value")
+-- set_session(:key).to{ calc_expectation }
-set_the_flash
+-- set_the_flash
+-- set_the_flash.to('value')
+-- set_the_flash.to(/regexp/)
+-- set_the_flash[:key]
+-- set_the_flash[:key].to('value')
+-- set_the_flash[:key].to(/regexp/)
+-- set_the_flash[:key].now
+-- set_the_flash[:key].to('value').now
くらいかもしれません。
+** shoulda-matcher の作り方 [#m38d0482]
+
+shoulda の matcher は matches?, description, failure_message などを実装した
+Matcher オブジェクトを作成するファクトリメソッドとして実装されます。
+
+それが分かっていれば上記 redirect_to_path のように、既存の matcher にパラメータを与えて作成して返すことは簡単にできます。
+
+Matcher クラスを1から自分で作る場合のやりかたは、set_session のコードを見れば一通り分かりそうです。
+
+https://github.com/thoughtbot/shoulda-matchers/blob/master/lib/shoulda/matchers/action_controller/set_session_matcher.rb
+
* 役立ちそうな記事 [#x64e134e]
- http://www.railstips.org/blog/archives/2009/02/21/shoulda-looked-at-it-sooner/