From 1a3aeec47cfb6c340f084a096829264d5bfbd80a Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Sun, 18 Sep 2011 21:40:47 +0700 Subject: [PATCH] Fix have_db_index_matcher bug on JRuby So matched_index.unique actually returns an integer instead of true and returns nil instead of false in JRuby. This `!!` operator should fix it. --- lib/shoulda/matchers/active_record/have_db_index_matcher.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/shoulda/matchers/active_record/have_db_index_matcher.rb b/lib/shoulda/matchers/active_record/have_db_index_matcher.rb index e3f03e30..a0a6e13c 100644 --- a/lib/shoulda/matchers/active_record/have_db_index_matcher.rb +++ b/lib/shoulda/matchers/active_record/have_db_index_matcher.rb @@ -58,11 +58,11 @@ module Shoulda # :nodoc: def correct_unique? return true if @unique.nil? - if matched_index.unique == @unique + if !!matched_index.unique == @unique true else @missing = "#{table_name} has an index named #{matched_index.name} " << - "of unique #{matched_index.unique}, not #{@unique}." + "of unique #{!!matched_index.unique}, not #{@unique}." false end end