• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

「RSpec1.1.5からはautospecでautotest相当のことができる」ということを#rails-tokyoのIRCで教えてもらいました。autospec(autotest)を使うと、specファイル保存時にrspecが走ります。ので、rake specとかruby script/rails_spec spec/models/testmodel_spec.rbとか毎回打つ必要がなくなります。余計なウィンドウ移動が減って、コードに集中できるのはすばらしい!

 

--
12:15 (ysakaki) WindowsXPの環境でRSpeccのautotest動かせてる方いますか?
12:19 (yoshuki_) こんにちは、1.1.5からautospecコマンドになってますよ
12:22 (ysakaki) なんと!
12:23 (walf444) autospecついてるけど中でautotestをsystemでよんでるだけと角谷さんがいってたような気がする
12:25 (ysakaki) でけました!
--

walf444さんありがとう!

posted by ysakaki ysakaki on Tue 9 Dec 2008 at 17:45 with 0 comments

.autotestを書き換えるたびに思い出すのに苦労するのでまとめておきます。

|caption=Hook List of autotest
|
|hook name,when does it happen?
|
|:initialize, 起動直後
|:interrupt, INT割り込み発生時
|:reset, 初期化の後およびING割り込み時の初期化が完了した後
|:run_command,テストの実行前
|:ran_command,テスト完了時
|:all_good, INTによる全体テストが成功裏に完了した場合
|:waiting, テスト実行完了後にsleepする直前
|:quit, 終了時

posted by genki genki on Tue 16 Sep 2008 at 08:16 with 0 comments

autotestでall_good時にrerun_all_testsをしないようにする
の改良版です。
handle_resultsメソッドの実装の変化を、
なるべく吸収できるような書き方に変えました。
~/.autotestに書いておくと良いかもしれません。

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

def handle_results(*args, &block)
handle_results_old(*args, &block)
self.tainted = !self.files_to_test.empty?
end
end
<<--

posted by genki genki on Tue 15 Jul 2008 at 21:52 with 0 comments

ちょっと昔のコードのRSpecをAutotest対応にした時の作業ログです。

script/spec

ruby>>
#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.expand_path(File.dirname(FILE) + "/../vendor/plugins/rspec/lib"))
require 'rubygems' #追加
require 'spec'
#::Spec::Runner::CommandLine.run(ARGV, STDERR, STDOUT, true, true)
::Spec::Runner::CommandLine.run(
::Spec::Runner::OptionParser.parse(ARGV, STDERR, STDOUT))
<<--

See Also

posted by genki genki on Wed 23 Apr 2008 at 23:26 with 0 comments