Jul
13th
Fri
13th
Rspec and RJS
Creating an rspec example for an RJS template is pretty straightforward:
it "should replace 'payment'" do
render "payments/new.rjs"
response.should have_rjs(:replace_html, "payment")
end
Currently have_rjs can not detect the use of proxies like:
page[:payment].replace_html :partial => "payment"
You need to use:
page.replace_html "payment", :partial => "payment"
I was wondering how to create an example for a partial being rendered on a replace_html RJS call. Still in the mindset of TDD instead of BDD, I was looking to assert the output.
Jake Scruggs put me on the right track: use mock expectations.
it "should replace with partial" do
@controller.template.should_receive(:render).with(:partial => 'partial_form')
render "payments/new.rjs"
end