This section is for questions on all topics. Please check here before submitting an issue.
:index is a special case. All other routes are defined by the symbol name as shown in the second example below.
SampleBlog::App.controllers :things do get :index do # some code end get :index, :map => 'things/' do # equivalent route to index above end get :other do # some code end get :other, :map => 'things/other/' do # equivalent route to other above end end
require '../test_config' require 'mail' # Explicitly load Mail Gem class MailTest < MiniTest::Test def setup app ProjectName::App do set :delivery_method, :test # emails are not sent and recorded in the test mailer end Mail::TestMailer.deliveries.clear # Unavailable pretesting unless mail required end def test_mail_is_sent get '/email_route' last_message = Mail::TestMailer.deliveries.pop assert last_message, 'Sent message exists' # Other assertions on last mail end end
A generated Padrino project includes csrf protect on all post requests. This should not be disabled at the app level, unless you know what you are doing. Csrf can be disable in an individual test suite by overwritting the
require_relative '../test_config' class ControllerTest < MiniTest::Test def setup app ProjectName::App do set :protect_from_csrf, false end end def test_post_to_server post '/request', data: 'information' refute_equal 403, last_response.status assert last_response.ok? end end