Ruby1.9.2p290でAutotestでRSpec2を試すも動かない
以下の状態でMacにて試した
ruby:1.9.2-p290
ZenTest:4.6.0
rpsec2:2.6.0
結論
以前の結論は全部破棄
正解はrubygemsのバージョンが古いせいでした。id:s-tomoさん情報ありがとうございました。
$ gem -v 1.6.2 $ autotest ~/.rvm/gems/ruby-1.9.2-p290/gems/ZenTest-4.6.0/lib/autotest.rb :226:in `autodiscover': undefined method `any?' for Gem::Specification:Class (NoMethodError) ... $ gem update --system Updating rubygems-update ... $ gem -v 1.8.6 $ autotest Finised in 0.00271 seconds 2 examples, 0 failures
以下消さないでおいておきますが、なんの意味も無い情報です。
the following infomation is useless
please update rubygems
超場当たり的な修正というか、改悪をかまして動くようにはなった。でもさすがに許されるものではない。
ZenTest-4.6.0/lib/autotest.rbの226行を変更
hacky_discovery = Gem::Specification.any? { |s| s.name =~ /^rspec/ } を hacky_discovery = true へと変更
として豪快な一時しのぎを行った。うちではautotestはRSpecでしか使ってないしまあええのではないかと自分に言い訳しまくりんぐであります。
その直前にZenTestの作者の方?のコメントでなんかRSpec2で動かなくて云々と色々書いてあったりします。ちゃんとRSpec2が動くようになったらこのへんは消すよとのこと。
経緯
$ autotest ~/.rvm/gems/ruby-1.9.2-p290/gems/ZenTest-4.6.0/lib/autotest.rb :226:in `autodiscover': undefined method `any?' for Gem::Specification:Class (NoMethodError) from ~/.rvm/gems/ruby-1.9.2-p290/gems/ZenTest-4.6.0/lib/autotest.rb :150:in `runner' from ~/.rvm/gems/ruby-1.9.2-p290/gems/ZenTest-4.6.0/bin/autotest :6:in `<top (required)>' from ~/.rvm/gems/ruby-1.9.2-p290/bin/autotest:19:in `load' from ~/.rvm/gems/ruby-1.9.2-p290/bin/autotest:19:in `<main>'
autospecを実行すると、rspec2からはこのコマンドはもう使えない、autotest使えと言われる。というわけでautotestを実行するとこんなエラーが。any?なんてメソッド知らないとのこと。確かにそんなメソッドは無さそうである。
226行を見るとGemのなんらかの情報にてname attributeにrpsecで始まるのがあったら、requireなどのロードパスにカレントを加えようねとなってるっぽい。
Gem::Specifiactionのリファレンス見る。でもすいません、も一つ良く分からない。
hacky_discovery = defined?(RSpec)
でいいんじゃね?とか思うものの当然のようにうまくいかず。
仕方が無いので一番上にある逃げを行いました。うーむ。どうしたらいいのだろうか。