Skip to content

Instantly share code, notes, and snippets.

@ismasan
Created February 11, 2009 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismasan/61974 to your computer and use it in GitHub Desktop.
Save ismasan/61974 to your computer and use it in GitHub Desktop.
module Spec
module Rails
module Matchers
def have_sane_through_associations
return simple_matcher(":through associations not to have the :dependent options}") do |model|
model = model.class if model.is_a? ActiveRecord::Base
not model.reflect_on_all_associations.any?{|a| a.options[:through] && a.options[:dependent]}
end
end
end
end
end
# Usage
User.should have_sane_through_associations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment