Van_Paitin
Van_Paitin

Reputation: 4248

How do I use the normal controller test assertions in Minitest Spec DSL

I usually write my specs in RSpec but I use Minitest too. Recently I learnt that there is a minitest dsl that could read like RSpec. They call it Minitest::Spec. I have checked it out and I think I like it. The gem 'minitest-rails' makes the setup configuration easy. There is however one limitation I have faced and that is in the integration specs. What is the equivalent for assertions like assert_response, assert_no_difference, and assert_template?

Upvotes: 0

Views: 238

Answers (1)

Van_Paitin
Van_Paitin

Reputation: 4248

I have seen an answer. It turned out that I got them in the very gem that supplied the test expectations. I looked into the source code of the minitest/rails/controller.rb and I saw the simple way those expectations were implemented is by aliasing the real minitest assertions. Here is my find

class ActionController::TestCase # :nodoc:
  alias :must_respond_with :assert_response
  alias :must_redirect_to :assert_redirected_to
  alias :must_render_template :assert_template
  alias :must_select :assert_select
  alias :must_select_email :assert_select_email
  alias :must_select_encoded :assert_select_encoded
end

Upvotes: 1

Related Questions