RSpecは面白そうだったのだけれど、なかなか移行する機会が無くて使っていなかったのですが、今は縁があってRSpecでViewのテストを書いています。

で、partialのテストをする場合のメモです。

   1  require File.join(File.dirname(__FILE__), '../../spec_helper.rb')
   2  
   3  describe '/foos/_form.html.erb' do
   4    before do
   5      render :partial => 'foos/form', :object => mock('form'),
   6        :locals => {:bar => mock('bar')}
   7    end
   8  
   9    it "should be rendered successfully" do
  10      response.should be_success
  11    end
  12  end

とりあえずこんな感じです。

See Also

posted by Png genki on Fri 16 May 2008 at 01:30 with 1 comment
Contents
RSpecでpartialをテストする場合のメモ
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
瀧内元気: おお、チェックしてみます。thx! '11-12
overisland: Reeder for iPhone もこの UI を実装していますね。 '11-12
瀧内元気: その情報は見たのですが、以下のサイトによると、現在はまた必要になってるっぽいんですよね。 ... '11-12
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ