How to deal with complex Factory Bot associations in RSpec tests
What’s the best way to handle tests that involve complex setup data? You want to test object A but it needs database records for objects B, C and D first.I’ll describe how I address this issue but first let me point out why complex setup data is a problem.Why complex setup data is a problemComplex setup data can be a problem for two reasons. First, a large amount of setup data can make for an Obscure Test, meaning the noise of the setup data drowns out the meaning of the test.Second, complex setup data can be a problem if it results in duplication. Then, if you ever need to change the setup steps, you’ll have to make the same change in multiple places.
How to deal with complex Factory Bot associations in RSpec tests #ruby #rails #rubyonrails #bosnia #programming #tutorials #rubydeveloper #railsdeveloper