<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/rails_root/db/migrate/008_create_dogs_fleas.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -415,23 +415,22 @@ module ThoughtBot # :nodoc:
         end
       end
   
-      # Ensures that the has_and_belongs_to_many relationship exists.  
+      # Ensures that the has_and_belongs_to_many relationship exists, and that the join
+      # table is in place.
       #
       #   should_have_and_belong_to_many :posts, :cars
       #
-      # NOTE:  One thing this macro should test, but doesn't is that the join
-      # table exists in the DB.  Please contact the author if you know of a DB
-      # agnostic way of introspecting on the current schema.
       def should_have_and_belong_to_many(*associations)
         get_options!(associations)
         klass = model_class
 
         associations.each do |association|
           should &quot;should have and belong to many #{association}&quot; do
-            assert klass.reflect_on_association(association), 
-                   &quot;#{klass.name} does not have any relationship to #{association}&quot;
-            assert_equal :has_and_belongs_to_many, 
-                         klass.reflect_on_association(association).macro
+            reflection = klass.reflect_on_association(association)
+            assert reflection, &quot;#{klass.name} does not have any relationship to #{association}&quot;
+            assert_equal :has_and_belongs_to_many, reflection.macro
+            table = reflection.options[:join_table]
+            assert ::ActiveRecord::Base.connection.tables.include?(table), &quot;table #{table} doesn't exist&quot;
           end
         end
       end</diff>
      <filename>lib/shoulda/active_record_helpers.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>102fe37adc9a9b2c23132791bf16c0ff13553b3b</id>
    </parent>
  </parents>
  <author>
    <name>Tammer Saleh</name>
    <email>tsaleh@thoughtbot.com</email>
  </author>
  <url>http://github.com/thoughtbot/shoulda/commit/28d9140a7ea45f9a305b251a544ead425fcd58e4</url>
  <id>28d9140a7ea45f9a305b251a544ead425fcd58e4</id>
  <committed-date>2008-04-26T14:42:14-07:00</committed-date>
  <authored-date>2008-04-26T14:42:14-07:00</authored-date>
  <message>fixed should_have_and_belong_to to test for the join table</message>
  <tree>f2dd24073247c9ccd8572e4d778c39247bcdad55</tree>
  <committer>
    <name>Tammer Saleh</name>
    <email>tsaleh@thoughtbot.com</email>
  </committer>
</commit>
