Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix test:prepare launch to depend on the ActiveRecord 'defined?' #795

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants

Exoth commented Aug 1, 2013

Fixes issue #794 in the same manner as in this old commit:

a5949a5

Exoth commented Aug 1, 2013

Did it in the 2-14 branch, as I couldn't even install bundle in the current master of the Rspec.

Exoth commented Aug 1, 2013

Travis seems to have failed because of a rubygems timeout. Needs to be restarted.

Owner

JonRowe commented Aug 2, 2013

(ping @alindeman)

Contributor

alindeman commented Aug 2, 2013

I think this change makes sense given that test:prepare could be database agnostic. Let's do it. I'll clean up and merge.

Contributor

alindeman commented Aug 2, 2013

Well, let's think about this some more.

What if I'm trying to use only MongoDB (Mongoid, MongoMapper) with my app? How do I make ActiveRecord get out of my way so that db:test:prepare for AR doesn't blow up?

Do I need to split up config/application.rb so the AR railtie is not brought in?

(Honestly it's been a while since I've tried to use MongoDB with a Rails app. Someone please refresh my memory.)

@samphippen samphippen commented on the diff Aug 3, 2013

lib/rspec/rails/tasks/rspec.rake
@@ -3,7 +3,7 @@ if default = Rake.application.instance_variable_get('@tasks')['default']
default.prerequisites.delete('test')
end
-spec_prereq = Rails.configuration.generators.options[:rails][:orm] == :active_record ? "test:prepare" : :noop
+spec_prereq = defined?(ActiveRecord) ? "test:prepare" : :noop
@samphippen

samphippen Aug 3, 2013

Owner

is ActiveRecord ever not defined in a rails app? what about a rails app that talks to RSpec?

@JonRowe

JonRowe Aug 3, 2013

Owner

Yes. If you don't pull in the ActiveRecord railtie then it's not defined. (I have several project like that because they use Mongo)

Owner

samphippen commented Aug 13, 2013

What's the status on this?

Contributor

alindeman commented Aug 13, 2013

I still have a few open questions (above) that I've not tried to figure out yet. Was hoping someone would know offhand.

Owner

JonRowe commented Aug 13, 2013

I've only used the db:test:prepare rake task with ActiveRecord, do other ORM's use it? It seems like Rails should take care of making it work with/without ActiveRecord...

Member

cupakromer commented Apr 27, 2014

This has grown stale. While it does not seem to be an issue to simply call db:test:prepare always, the discussion in #949 bring up some valid arguments. Closing in favor of the decision made there.

@cupakromer cupakromer closed this Apr 27, 2014

Owner

JonRowe commented Apr 27, 2014

While it does not seem to be an issue to simply call db:test:prepare always

The task doesn't always exist (at all on 4.1)

Member

cupakromer commented Apr 27, 2014

@JonRowe right, sorry, I was specifically referring to <= 4.0.x. Rails 4.1 is a new beast which I think is being tackled already via 949.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment