Reputation: 10393
# controller
def index
p = params[:p]
raise ABCException if p
end
# test
test "expect index controller raise ABCException" do
assert_raise ABCException do
# how do I write this block?
end
end
I would like to call the index controller with :p => true to raise an exception. I understand the assert_raise function, but don't know how to call controller as same as an end-user requests.
Upvotes: 0
Views: 37
Reputation: 25757
You can do
assert_raise ABCException do
get :index, :p => true
end
Upvotes: 2