16th
Fri
RSpecでpartialをテストする場合のメモ
RSpecは面白そうだったのだけれど、なかなか移行する機会が無くて使っていなかったのですが、今は縁があってRSpecでViewのテストを書いています。
で、partialのテストをする場合のメモです。
1 require File.join(File.dirname(__FILE__), '../../spec_helper.rb ') 2 3 describe '/foos/_for m.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 successful ly" do 10 response.should be_success 11 end 12 end
とりあえずこんな感じです。
See Also