こちら で、ExceptionNotifierプラグインのテンプレートに関するバグの報告が出ていました。

Plugins - Exception Notifier

Brett Neumeier 12 Oct 2007

In ruby 1.8.6p111, rendering the _environment.rhtml plugin fails with "TemplateError: flag after width". This is fixed if you change the string "%-s" to "%-s" on line three of the template.

Chris 18 Oct 2007

This is the correct string: "%-*s:"

具体的には、views/exception_notifier/_environment.rhtml の3行目を次のように修正すればOKのようです。

views/exception_notifier/_environment.rhtml

<% max = @request.env.keys.max { |a,b| a.length <=> b.length } -%>
<% @request.env.keys.sort.each do |key| -%>
* <%= "%-*s: %s" % [max.length, key, filter_sensitive_post_data_from_env(key, @request.env[key].to_s.strip)] %>
<% end -%>

手元の環境(ruby-1.8.6 p36/Rails-1.99.0)では、これで問題なく動作するようになりました。

posted by Png genki on Thu 15 Nov 2007 at 05:07

Railsのプラグインは非常に便利な仕組みなのですが、pluginのテスト とうまく付き合うにはちょっと工夫が必要です。

plugin用に書かれているテストは、二通りの方法で実行される可能性があります。

  1. plugin ディレクトリの中で rake コマンドた実行された場合
  2. RAILS_ROOT から rake test:plugins が実行された場合

いくつかのプラグインは、上記の片方のケースのみを想定して test が書かれている場合があり、想定されていないケースからテスト が実行された場合、多くは沢山のエラーを出すようになります。

このような場合、プラグインディレクトリのRakefileに手を加えて、 呼び出し元に応じて処理を分けたりすれば、一見うまくいきそうですが、 そう簡単にはいきません。

Railsの test:plugins の仕組みは、プラグインディレクトリの Rakefileを参照せずに、直接 test ディレクトリの中身を実行する からです。

この挙動はあまり良くないと思うのですが、とりあえず、 rake test:plugins から実行するとエラーを出すプラグインの テストディレクトリの名前を plugin_test 等に変更して、 プラグインのRakefileを以下のように書き換えることで回避できます。

Rakefile

   1  desc 'Test the acts_as_taggable_on_steroids plugin.'
   2  Rake::TestTask.new(:test) do |t|
   3    t.libs << 'lib'
   4    t.pattern = 'plugin_test/**/*_test.rb'
   5    t.verbose = true
   6  end

これによって、上記 1 のケースでは正常に動作し、2 のケースではSkipされるため、エラーの山を見ることから逃れられます。

posted by Png genki on Thu 15 Nov 2007 at 02:13
undefined method `<<' for nil:NilClass
posted by Png genki on Thu 15 Nov 2007 at 01:34
Contents
ExceptionNotifierプラグインのバグ情報
プラグインのテストとうまく付き合う方法
acts_as_taggable_on_steroidsのplugin testを通す
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
瀧内元気: おお、チェックしてみます。thx! '11-12
overisland: Reeder for iPhone もこの UI を実装していますね。 '11-12
瀧内元気: その情報は見たのですが、以下のサイトによると、現在はまた必要になってるっぽいんですよね。 ... '11-12
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ