Skip to content

Loading…

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

Closed
wants to merge 1 commit into from

5 participants

@Exoth

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

a5949a5

@Exoth

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

@Exoth

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

@JonRowe
RSpec member

(ping @alindeman)

@alindeman

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

@alindeman

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
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 RSpec member

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

@JonRowe RSpec member
JonRowe added a note

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)

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

What's the status on this?

@alindeman

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

@JonRowe
RSpec member

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...

@cupakromer
RSpec member

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
@JonRowe
RSpec member

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)

@cupakromer
RSpec member

@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
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/rspec/rails/tasks/rspec.rake
View
2 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 RSpec member

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

@JonRowe RSpec member
JonRowe added a note

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
task :noop do; end
task :default => :spec
Something went wrong with that request. Please try again.