-
Notifications
You must be signed in to change notification settings - Fork 177
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
Avoiding conflicts with shoulda-matchers #209
Comments
Now I have another conflict on something working usually with the following test: it { should belong_to(:city).inverse_of(:city_names) } which fails with:
|
Interesting, I am not sure what to do about this, but looks like a regular name collision to me. Does this mean we should rename some functions here? |
Well, I forgot to update this issue, but I solved it by changing the way to load the I changed the ...
RSpec.configure do |config|
config.include Mongoid::Matchers, type: :model
...
end from ...
RSpec.configure do |config|
config.include Mongoid::Matchers, type: :mongoid_model
...
end Then the ActiveRecord models are described as 2 options in my eyes:
|
I would prefer both? If you're doing the minimum maybe PRing (2)? |
I can do the |
Whatever you can do @zedtux we'll appreciate it. |
We ran into this issue after upgrading to Mongoid 7 (from
Since we use matchers from both libraries in our specs, we managed to work around the issue by changing the order of the included modules in RSpec.configure do |config|
# Mongoid matchers must be included after shoulda's active model support,
# since we want the mongoid version of validate_presence_of from mongoid-rspec.
config.include Shoulda::Matchers::ActiveModel, type: :model
config.include Mongoid::Matchers, type: :model
end
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :action_controller
# with.library :active_model # inclusion of Shoulda::Matchers::ActiveModel is done manually, see above
end
end |
In #161 (which also deals with shoulda-matchers compatibilty), it is suggested that conflicting matchers should have an alias. Perhaps that could be a solution here? |
It worked, perfectly for us, thank you a lot @zedtux |
I have a Rails application composed of a mixture of ActiveRecord and Mongoid models.
I was able to write my unit tests until now the having configured my
rails_helper.rb
file has the following:But I have a conflict now that I want to use the
validate_length_of
matcher.I have a spec file of an ActiveRecord model like this:
But it is failing with the following error:
Is there a way I can tell to RSpec this is a Mongoid model (
type: :mongoid_model
?) which would load only themongoid-rspec
matchers?The text was updated successfully, but these errors were encountered: