[Rspec-devel] Rspec on Rails - 'lock_mutex' is missing?

Jonathan del Strother maillist at steelskies.com
Thu Jun 29 13:26:01 EDT 2006


Oh.  Looked what happened to Rails' transactions.rb on revision 4460  
(19th June) :

-      def lock_mutex#:nodoc:
-        Thread.current['open_transactions'] ||= 0
-        TRANSACTION_MUTEX.lock if Thread.current 
['open_transactions'] == 0
-        Thread.current['start_db_transaction'] = (Thread.current 
['open_transactions'] == 0)
-        Thread.current['open_transactions'] += 1
-      end
-
-      def unlock_mutex#:nodoc:
-        Thread.current['open_transactions'] -= 1
-        TRANSACTION_MUTEX.unlock if Thread.current 
['open_transactions'] == 0
-      end
+
+      private
+        def increment_open_transactions #:nodoc:
+          open = Thread.current['open_transactions'] ||= 0
+          Thread.current['start_db_transaction'] = open.zero?
+          Thread.current['open_transactions'] = open + 1
+        end
+
+        def decrement_open_transactions #:nodoc:
+          Thread.current['open_transactions'] -= 1
+        end


That would explain a lot.


Jon



On 29 Jun 2006, at 18:11, Jonathan del Strother wrote:

> I've just installed rspec on a bleeding-edge Rails installation.   On
> trying to run the default spec, I got this:
>
> ==
>
> (in /Users/jon/Developer/OneMod)
> ruby -Ilib "/usr/local/lib/ruby/gems/1.8/gems/rspec-0.5.13/bin/
> spec"   "spec/models/active_user_spec.rb"
>
> FF
>
> 1)
> NoMethodError in 'ActiveUser class with fixtures loaded should count
> two ActiveUsers'
> undefined method `lock_mutex' for ActiveRecord::Base:Class
> /Users/jon/Developer/OneMod/config/../vendor/rails/activerecord/lib/
> active_record/base.rb:1177:in `method_missing'
>
> 2)
> NoMethodError in 'ActiveUser class with fixtures loaded should have
> more specifications'
> undefined method `lock_mutex' for ActiveRecord::Base:Class
> /Users/jon/Developer/OneMod/config/../vendor/rails/activerecord/lib/
> active_record/base.rb:1177:in `method_missing'
>
> Finished in 0.032169 seconds
>
> 2 specifications, 2 failures
> rake aborted!
> RSpec failures
>
>
> ==
>
>
>
> The lock_mutex method doesn't seem to exist anywhere in ActiveRecord.
> I 'fixed' this by replacing lock_mutex & unlock_mutex in
> fixture_loading.rb  with
> "ActiveRecord::Base.send :increment_open_transactions" and
> "ActiveRecord::Base.send :decrement_open_transactions", which seems
> to work, but I'm not familiar enough with either rspec or rails to
> say that this is the correct way of doing things.
>
> Is no-one else getting this error?  I couldn't find any references to
> it anywhere.
>
>
> Jon
> _______________________________________________
> Rspec-devel mailing list
> Rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel



More information about the Rspec-devel mailing list