タグ

ブックマーク / yohfee.hatenadiary.org (2)

  • すごいぞRSpec(shared example group編) - @yohfee.blog!

    ちょっと前に話題になったRSpecのスライドがステキだったよね。でもRSpecはまだまだ底知れない気がするので自分でもいろいろと調べてみようと思った次第。 まずはrspec-core(2.5.1)/features/example_groups/shared_example_group.featureを参考にshared example groupについて調べてみたよ。 例1:テストを共有できる require "set" shared_examples_for 'a collection' do subject { described_class.new [7, 2, 4] } its(:size) { should eq 3 } it { should include 7 } it { should_not include 9 } end describe Array do it_be

    すごいぞRSpec(shared example group編) - @yohfee.blog!
    patorash
    patorash 2014/04/04
    いろんな表現があるんだな。
  • RSpec Railsで名前付きルートのテスト - @yohfee.blog!

    シリーズ(?)の途中ですが軽く脱線。 route_toマッチャを使うと出来るみたい。名前付きじゃなくてもroute_toマッチャ使うんだけどね。ルーティング可能かどうかだけならbe_routableマッチャでよさげ。 spec:routingタスクでルーティングだけテストできる。 % rake spec:routing routes to the pages controller GET root_path should be routable should route to {:controller=>"pages", :action=>"home"} GET service_path should be routable should route to {:controller=>"pages", :action=>"service"} Finished in 0.12806 seco

    RSpec Railsで名前付きルートのテスト - @yohfee.blog!
    patorash
    patorash 2013/01/06
    こういうふうにも書けるんやなー。
  • 1