Kerry Buckleyさん?のRSpecのスライドが凄くいいです。
RSpec
3分の1くらい知らない内容が載っていた感じです。
読みやすくとても良く纏まってるので
また何度か読み返すと思います。
気になったとこ
fuubar
テストの進行具合をプログレスバー表示してくれる
かわいいツールです。早速installしてみます。
$ gem install fuubar Fetching: rspec-instafail-0.1.5.gem (100%) Fetching: fuubar-0.0.3.gem (100%) Fetching: rspec-core-2.4.0.gem (100%) ************************************************** Thank you for installing rspec-core-2.4.0 Please be sure to look at the upgrade instructions to see what might have changed since the last release: http://github.com/rspec/rspec-core/blob/master/Upgrade.markdown ************************************************** Fetching: rspec-expectations-2.4.0.gem (100%) Fetching: rspec-mocks-2.4.0.gem (100%) Successfully installed rspec-instafail-0.1.5 Successfully installed fuubar-0.0.3 Successfully installed rspec-core-2.4.0 Successfully installed rspec-expectations-2.4.0 Successfully installed rspec-mocks-2.4.0
実行結果
$ rspec -f Fuubar spec/ 56/56: 100% |==========================================| Time: 00:00:00 Finished in 0.55649 seconds 56 examples, 0 failures
まぁ、悪くないです。
profile
$ rspec --profile spec -c ........................................................ Top 10 slowest examples: Majang 1112345678999 0.07475 seconds ./spec/lib/majang_spec.rb:39 Majang 1112345678999 0.07276 seconds ./spec/lib/majang_spec.rb:47 App GET / 0.06609 seconds ./spec/app_spec.rb:7 Majang 1112345678999 0.02858 seconds ./spec/lib/majang_spec.rb:46 Majang 1112345678999 0.0189 seconds ./spec/lib/majang_spec.rb:45 Majang 1112345678999 0.01833 seconds ./spec/lib/majang_spec.rb:38 Majang 1112345678999 0.01811 seconds ./spec/lib/majang_spec.rb:42 Majang 1112345678999 0.01583 seconds ./spec/lib/majang_spec.rb:37 Majang 1112345678999 0.01583 seconds ./spec/lib/majang_spec.rb:43 Majang 1112345678999 0.01547 seconds ./spec/lib/majang_spec.rb:48 Finished in 0.52669 seconds 56 examples, 0 failures
exampleの処理時間でソートしてくれます。
これも悪くないです。
filtering
tag、version、名前によるfiltering機能があるんですね。
知りませんでした。
let
懐かしいbowling gameが例に出されていました。
describe BowlingGame do let(:game) { BowlingGame.new } it "scores all gutters with 0" do 20.times { game.roll(0) } game.score.should == 0 end it "scores all 1s with 20" do 20.times { game.roll(1) } game.score.should == 20 end end
letを指定することで、インスタンス変数の使用が抑えられます。見た感じすっきりします。
(多分、ここらへん一度勉強したけど忘れてたっぽいなぁ)