Testing Ruby on Rails Migrations
21-Mar-2019 1823
How do you test the code into the up method that creates a new record on a newly added association between User and Email before removing the email column from the User table?It’s a pretty common scenario and you could think that this logic should live into a separate object that you can test in isolation. I agree, but you still can’t really test it since if you call that object with the last version of your database schema (after this migration run), you’ll have an exception since User has no more the email column. 🤷This example is easily fixable by just stubbing the email message on any instance of User:.
Testing Ruby on Rails Migrations #ruby #rubydeveloper #rubyonrails #Testing #Rails #Migrations #testing https://rubyonrails.ba/link/testing-ruby-on-rails-migrations