Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

rspec fixes for 1.2.4 (thanks Daniel DeLeo)

  • Loading branch information...
commit 3fd70d89f46ee5d6c55b38055a670cf5ab06910b 1 parent a10d36c
Aman Gupta authored
57  lib/em/rspec/example_group_methods.rb
... ...
@@ -0,0 +1,57 @@
  1
+module Spec
  2
+  module Example
  3
+    module ExampleMethods
  4
+
  5
+      alias :original_execute :execute
  6
+      def execute(options, instance_variables)
  7
+        begin
  8
+          success = original_execute(options, instance_variables)
  9
+        ensure
  10
+          resume_on_error unless success
  11
+          Fiber.yield
  12
+        end
  13
+      end
  14
+
  15
+      def done
  16
+        EM.next_tick{
  17
+          :done.should == :done
  18
+          $em_spec_fiber.resume if $em_spec_fiber
  19
+        }
  20
+      end
  21
+
  22
+      private
  23
+
  24
+      def resume_on_error
  25
+        EM.next_tick{
  26
+          $em_spec_fiber.resume if $em_spec_fiber
  27
+        }
  28
+      end
  29
+
  30
+    end
  31
+
  32
+    module ExampleGroupMethods
  33
+
  34
+      alias :run_without_em :run
  35
+      def run( run_options )
  36
+        if options[:scope] == EventMachine::Spec::Rspec
  37
+          EM.run do
  38
+            run_in_fiber( run_options )
  39
+          end
  40
+        else
  41
+          run_in_fiber( run_options )
  42
+        end
  43
+        true
  44
+      end
  45
+
  46
+      private
  47
+
  48
+      def run_in_fiber( run_options )
  49
+        ($em_spec_fiber = Fiber.new{
  50
+          run_without_em( run_options )
  51
+          EM.stop_event_loop if EM.reactor_running?
  52
+        }).resume
  53
+      end
  54
+
  55
+    end
  56
+  end
  57
+end
58  lib/em/spec/rspec.rb
@@ -10,60 +10,4 @@ def self.spec( args, blk )
10 10
   end
11 11
 end
12 12
 
13  
-module Spec
14  
-  module Example
15  
-    module ExampleMethods
16  
-      
17  
-      alias :original_execute :execute
18  
-      def execute(options, instance_variables)
19  
-        begin
20  
-          success = original_execute(options, instance_variables)
21  
-        ensure
22  
-          resume_on_error unless success
23  
-          Fiber.yield
24  
-        end
25  
-      end
26  
-      
27  
-      def done
28  
-        EM.next_tick{
29  
-          :done.should == :done
30  
-          $em_spec_fiber.resume if $em_spec_fiber
31  
-        }
32  
-      end      
33  
-      
34  
-      private
35  
-      
36  
-        def resume_on_error
37  
-          EM.next_tick{
38  
-            $em_spec_fiber.resume if $em_spec_fiber
39  
-          }
40  
-        end
41  
-      
42  
-    end
43  
-    
44  
-    module ExampleGroupMethods
45  
-
46  
-      alias :run_without_em :run
47  
-      def run( run_options )
48  
-        if options[:scope] == EventMachine::Spec::Rspec
49  
-          EM.run do
50  
-            run_in_fiber( run_options )
51  
-          end
52  
-        else
53  
-          run_in_fiber( run_options )
54  
-        end    
55  
-        true
56  
-      end
57  
-
58  
-      private
59  
-      
60  
-        def run_in_fiber( run_options )
61  
-          ($em_spec_fiber = Fiber.new{
62  
-            run_without_em( run_options )
63  
-            EM.stop_event_loop if EM.reactor_running?
64  
-          }).resume   
65  
-        end  
66  
-
67  
-    end
68  
-  end
69  
-end
  13
+require File.dirname(__FILE__) + '/../rspec/example_group_methods'

0 notes on commit 3fd70d8

Please sign in to comment.
Something went wrong with that request. Please try again.