昔は違った気がするのですが、手元の環境のautotest(ZenTest-3.10.0)とRSpec-1.1.4を使った状態で、テスト中に一度例外が発生した後に、全てのテストをgreenにすると、全てのテストがもう一回全部実行されるという現象が起きています。

全部テストを実行するのは大変なので、とりあえず、.autotest
でパッチを当てて回避しました。

ruby>>
class Autotest
alias_method :handle_results_old, :handle_results
undef_method :handle_results

def handle_results(results)
failed = results.scan(self.failed_results_re)
completed = results =~ self.completed_re

self.files_to_test = consolidate_failures failed if completed

color = completed && self.files_to_test.empty? ? :green : :red
hook color unless $TESTING

#self.tainted = true unless self.files_to_test.empty?
self.tainted = !self.files_to_test.empty?

end
end
<<--

L14-15行目が修正箇所です。

posted by genki genki on Sun 6 Jul 2008 at 11:41 with 0 comments

メモもかねて。

MacBookにRailsの自動テスト環境を構築した

RAILS_ROOTでautotestを実行。起動時に全部のテストを実行するのでちょっとだけ重くなるかもしれません。それ以降はテストファイルやモデル、コントローラファイルなどを修正する度に該当のテストが走ります。

autotestを-fオプションを付けて立ち上げると、Fast startモードになり、最初に全部のテストを実行しなくなります。

posted by genki genki on Sun 6 Jul 2008 at 10:47 with 0 comments

KagemushaでActiveRecordのfindなどのクラスメソッドをswap
しようとすると、

pre>>
singleton method bound for a different object (TypeError)
<<--

というエラーが発生するという問題がありました。

このままでは困るので、とりあえず動くようにしてみました。
Unboundにしなければ問題は起こらないと思ったので、
instance_methodの代わりにalias_methodを使っています。

kagemusha_core_ext.rb

ruby>>
require 'uuidtools'

class Kagemusha #:nodoc:
def swap #:nodoc:
original_class_methods = {}
original_instance_methods = {}

@class_methods.each { |name, proc|
  if proc
    begin
      # replace method
      #method = @meta.instance_method(name)
      method = random_name
      @meta.instance_eval { alias_method method, name }
      @meta.instance_eval { define_method(name, proc) }
      original_class_methods[name] = method
    rescue NameError
      # insert method
      @meta.instance_eval { define_method(name, proc) }
      original_class_methods[name] = false
    end
  else
    begin
      # remove method
      #method = @meta.instance_method(name)
      method = random_name
      @meta.instance_eval { alias_method method, name }
      @meta.instance_eval { undef_method(name) }
      original_class_methods[name] = method
    rescue NameError
      # nop
    end
  end
}

@instance_methods.each { |name, proc|
  if proc
    begin
      # replace method
      method = @klass.instance_method(name)
      @klass.instance_eval { define_method(name, proc) }
      original_instance_methods[name] = method
    rescue NameError
      # insert method
      @klass.instance_eval { define_method(name, proc) }
      original_instance_methods[name] = false
    end
  else
    begin
      # remove method
      method = @klass.instance_method(name)
      @klass.instance_eval { undef_method(name) }
      original_instance_methods[name] = method
    rescue NameError
      # nop
    end
  end
}

return yield

ensure
original_class_methods.each { |name, method|
if method
# replace method
#@meta.instance_eval { define_method(name, method) }
@meta.instance_eval { alias_method name, method }
@meta.instance_eval { undef_method method }
else
# remove method
@meta.instance_eval { undef_method(name) }
end
}
original_instance_methods.each { |name, method|
if method
# replace method
@klass.instance_eval { define_method(name, method) }
else
# remove method
@klass.instance_eval { undef_method(name) }
end
}
end

private
def random_name
[UUID.random_128].pack("m").tr("=\n", '')
end
end
<<--

posted by genki genki on Sun 6 Jul 2008 at 02:28 with 2 comments
Contents rssrss
光ファイバーを二次元振動させて走査するAR用ディスプレイ
因果の取り違え
Swift2's defer for CoffeeScript
mongodb-3.0からcreateIndexのdropDupsが無くなったらしい
mongodb-3.0以降のWiredTigerの設定を動的に変更する方法
一般楕円の高速生成アルゴリズムへの道標
farro mantecatoのレシピ
Droonga関連の記事のまとめ
RuntimeErrorの特定のメッセージに限定してrescueする方法
jQueryでscriptタグを実行せずにappendする
Tags
memorubytesttipslib
Comments rssrss
瀧内元気 瀧内元気: MacOS版は以下にあります genki/ViMouse 01/16 05:40
dsjf dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これでも出... 01/08 23:23
瀧内元気 瀧内元気: おお、チェックしてみます。thx! 12/24 05:23
overisland overisland: Reeder for iPhone もこの UI を実装していますね。 12/24 05:13
瀧内元気 瀧内元気: その情報は見たのですが、以下のサイトによると、現在はまた必要になってるっぽいんですよね。 http:... 12/01 12:20
tkawa tkawa: http://devcenter.heroku.com/articles/rails31_herok... 12/01 10:47
瀧内元気 瀧内元気: どもー。いまはgithubに置いてあります https://github.com/genki/irb... 07/10 08:31
ともち ともち: こんにちは! すばらしいプログラムをありがとうございます。しかし、merbiのドメイン、切れているみ... 07/10 02:30
Services from s21g
YOMU Web小説リーダー
YOMUは、Web小説の読み上げに特化したiPhoneアプリです。
補助探
公開されている補助金・助成金情報を集約し、条件に合う制度を探しやすくするサービスです。
jotter.me
個人開発者のためのホスティング一体型ノートサービス
ハンドミラー
iPhone向けの手鏡アプリ
ツイプロ(twpro)
Twitterプロフィールの高速検索エンジン