thoughtbot--shoulda-matchers/lib/shoulda/matchers/active_record
Elliot Winkler b4bf814b3b 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
2014-11-06 14:15:00 -07:00
..
association_matchers Fix association matchers + namespaced class_name 2014-11-06 14:15:00 -07:00
accept_nested_attributes_for_matcher.rb Updated accept_nested_attributes_for_matcher docs [ci skip] 2014-08-27 15:16:15 -03:00
association_matcher.rb Fix association matchers + namespaced class_name 2014-11-06 14:15:00 -07:00
association_matchers.rb Extract examples in README to inline documentation 2014-06-20 16:41:27 -06:00
define_enum_for_matcher.rb Add documentation, news for define_enum_for 2014-08-28 10:55:52 -06:00
have_db_column_matcher.rb Delete unused variable 2014-06-27 14:41:54 -06:00
have_db_index_matcher.rb Extract examples in README to inline documentation 2014-06-20 16:41:27 -06:00
have_readonly_attribute_matcher.rb Extract examples in README to inline documentation 2014-06-20 16:41:27 -06:00
serialize_matcher.rb Extract examples in README to inline documentation 2014-06-20 16:41:27 -06:00