tkymtk's blog

Ruby on Rails及びその周辺について調べたこと。Do whatever you want to do at your own pace.

RSpecで試行錯誤

RSpec--format documentation を付けて実行したときに、結果がいい感じになるように工夫した過程。(だいたい)

最初

describe MatchAddress do
   describe '#call' do
     describe '000-0000' do
       address = described_class.new('000-0000').call
       it { expect(address).to eq 'True' }
     end
  end
end

output

MatchAddress
  #call
    000-0000
      should eq "True"

outputは悪くないけど、他の数字のケースでspecを書くのがめんどくさそうだ。また、重複する処理もある。

次: shared_examples使ってみよう

続きを読む
間違いがあれば、ご指摘下さると幸いです。