Testing page.alert

Hello,

Testing newbie here. I have some AJAX code that would render an error message back to the host using page.alert. How would I test that? Personally I use RSpec, but Test::Unit is also fine. Thanks.

# If some error arises render :update do |page|   page.alert("Error message!") end

Here's how you can do it with rspec:

describe "some action" do   it "should alert with Error message!" do     page = mock("page")     page.should_receive(:alert).with("Error message!")     controller.expect_render(:update).and_yield(page)     get :some_action   end end

Here's how I *think* (haven't tried it, but should work) you can do it with test/unit and mocha:

def test_alert_with_error_messaged     page = mock()     page.expects(:alert).with("Error message!")     @controller.expects(:update).yields(page)     get :some_action end

Cheers, David