-
-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can no longer load acts_as_list in isolation if Rails is installed #145
Comments
You mean,
right? |
Correct. The app is a Rails app, but I unit test the models in isolation, only loading direct dependencies like ActiveRecord and acts_as_list. This gives me sub-second responses from my unit tests, and design feedback from the tests about # of dependencies, etc. |
@botandrose Sorry for slowing down your tests, but I'm curious, how would you execute your Rails app tests without bundling rails? |
Hi, @amatsuda! Most of my Rails apps have two separate test suites: a high-level acceptance test suite, and a low-level unit test suite. Both suites are pushed as far as possible in their respective directions, and yield very different benefits. The acceptance tests are as high-level as possible, so they boot Rails, load all the dependencies, and test the happy path through every feature in a black-box fashion (capybara & poltergeist). These tests drive outside-in feature development, check basic correctness, and ensure everything is wired up together, but provide very little code design feedback (if any), nor do they cover edge cases or sad paths. They are also very slow, in the order of magnitude of minutes. The unit tests, in contrast, are as low-level as possible, so they test only one object at a time in complete isolation (no booting Rails!), while mocking and stubbing any collaborators. This provides excellent code design feedback and forces one to consider things like SRP, cohesion, interfaces, dependencies, etc etc. TDDing with truly sub-second test suites is a really wonderful thing, also. :) Does this show where I'm coming from? I know not everyone does this, but it works really well if you take the time to do it. To answer your other question, I do not use |
@botandrose Thank you for explaining clearly! Although I don't follow your practice, I do understand what you're aiming at. Just made a comment to your PR #146. |
Hello, thanks for maintaining acts_as_list!
I like to unit test my models in isolation from rails, but this is no longer possible if the model depends on acts_as_list, since
require 'acts_as_list'
now requires rails, as of #114 . Simplest solution would be to revert the PR, but it'd be nice to get the best of both worlds. Could we replacerequire 'rails'
with a test fordefined?(Rails)
, or something similar? \cc @amatsudaThe text was updated successfully, but these errors were encountered: