Testing controllers with Minitest

17,776

Yes, you can use Minitest to test a controller. Testing a controller using Minitest is no different than testing a controller using Test::Unit. Any examples you find, like the Rails Guide, are supported.

http://guides.rubyonrails.org/testing.html#functional-tests-for-your-controllers

Share:
17,776

Related videos on Youtube

99miles
Author by

99miles

Updated on June 24, 2022

Comments

  • 99miles
    99miles almost 2 years

    I'm trying to find examples of testing controllers with Minitest, but I've only found a couple and the just verify what template is rendered and that 'success' is returned. That doesn't seem very helpful to me. Is Minitest used to test controllers?

    The Railscast ( http://railscasts.com/episodes/327-minitest-with-rails ) and a couple other posts I've found seem to do model tests with Minitest and integration tests with Capybara.

    What about controller tests? Can they be tested with Minitest? If so, are there any real-world examples that actually test the actions? It seems very odd that I can't find any after literally hours of searching.

    I know this is vague, but I'm trying to decide if I should go with RSpec or Minitest, but without having a clue how to truly test a controller with Minitest, I'm not seeing how it's even really an option, yet I keep reading some general rave reviews about it.

  • Nathan Hinchey
    Nathan Hinchey almost 4 years
    This answer is 8 years old. Is it still valid? Controllers now use ActionDispatch::IntegrationTest not Test::Unit.