• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

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

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

ruby>>
require File.join(File.dirname(FILE), '../../spec_helper.rb')

describe '/foos/_form.html.erb' do
before do
render :partial => 'foos/form', :object => mock('form'),
:locals => {:bar => mock('bar')}
end

it "should be rendered successfully" do
response.should be_success
end
end
<<--

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

See Also

posted by genki genki on Fri 16 May 2008 at 01:23 with 1 comment