-
-
Notifications
You must be signed in to change notification settings - Fork 909
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix association matchers + namespaced class_name
Fix `class_name` qualifier for association matchers so that if the model being referenced is namespaced, the matcher will correctly resolve the class before checking it against the association's `class_name`. Take these models for instance: module Models class Friend < ActiveRecord::Base end class User < ActiveRecord::Base has_many :friends, class_name: 'Friend' end end Here, the `has_many` is referring to Models::Friend, not just Friend. Previously in order to test the association, you had to write: describe Models::User do it { should have_many(:friends).class_name('Models::Friend') } end Now, `have_many` will attempt to resolve the string given to `class_name` within the context of the namespace first before treating it as a reference to a global constant. This means you can now write this: describe Models::User do it { should have_many(:friends).class_name('Friend') } end
- Loading branch information
Showing
5 changed files
with
176 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters