diff --git a/lib/shoulda/active_record/macros.rb b/lib/shoulda/active_record/macros.rb index 2ac63b7f..cda466d5 100644 --- a/lib/shoulda/active_record/macros.rb +++ b/lib/shoulda/active_record/macros.rb @@ -457,7 +457,9 @@ module ThoughtBot # :nodoc: dependent = get_options!(associations, :dependent) klass = model_class associations.each do |association| - should "have one #{association}" do + name = "have one #{association}" + name += " dependent => #{dependent}" if dependent + should name do reflection = klass.reflect_on_association(association) assert reflection, "#{klass.name} does not have any relationship to #{association}" assert_equal :has_one, reflection.macro @@ -476,7 +478,7 @@ module ThoughtBot # :nodoc: end assert associated_klass.column_names.include?(fk.to_s), "#{associated_klass.name} does not have a #{fk} foreign key." - + if dependent assert_equal dependent.to_s, reflection.options[:dependent].to_s, diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 1590bf5f..da633116 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -9,6 +9,7 @@ class UserTest < Test::Unit::TestCase should_have_many :friendships should_have_many :friends + should_have_one :address should_have_one :address, :dependent => :destroy should_have_indices :email, :name, [:email, :name]