What is the Rails method for organizing unit tests?

When creating unit tests in a Rails project, the first question I asked myself was โ€œwhat is the agreement for organizing unit testsโ€ because almost everything else is dictated by the agreement. Also, I'm curious if the agreement between MiniTest, TestUnit, and Rspec is changing.

What I have done so far is mirroring the Rails directory structure in my test / unit directory, for example:

[Rails Root]
 /lib/
  ./postgres.rb
  ./awesome_parser.rb
 /app/helpers
  ./psychic_helper.rb

 /test/unit/
  ./lib/postgres.rb
  ./lib/awesome_parser.rb
  ./app/helpers/psychic_helper

What is the most common way to organize tests, so when others jump on this project they donโ€™t curse my name?

+3
source share
1 answer

Rspec , , 'app', . ( rails):

spec/controllers/user_controller_spec.rb
spec/models/user_spec.rb
spec/helpers/user_helpers_spec.rb

lib :

spec/lib/user_stuff_spec.rb

, :

spec/integration/route_specs.rb

Spec :

spec/support/custom_matchers.rb

, , :

spec/factories/user_factories.rb
+4

All Articles