shlogg · Early preview
Jetthoughts Dev @jetthoughts

Avoiding Method Name Conflicts In Minitest::Unit Tests

Avoid using `message`, `time`, `pass` & `name` as method names in Minitest::Unit test cases to prevent unexpected results. These names are reserved for internal use by Minitest::TestCase.

**TL,DR: *don’t define any methods with names name, message, time, pass in Minitest::Unit test cases unless you really want to override those of Minitest::TestCase.*
When writing Minitest::Unit tests, it’s convenient to use test case’s instance methods as kind of RSpec’s lazy-evaluated let-blocks or various helper methods.

class TrialPeriodVideoDownloadTest < ActiveSupport::TestCase
  def user
    users(:trial_period_bob)
  end
  def video
    videos(:fullhd_video_private)
  end
  test 'trial user can download private video' do 
    travel_to user.registered_at
    assert VideoPolicy.new(user...