ismasan (owner)

Revisions

gist: 61974 Download_button fork
public
Public Clone URL: git://gist.github.com/61974.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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