Skip to content
This repository
Browse code

Fix compatibility with rspec 2.11

  • Loading branch information...
commit bcf23c3e69012e5e068b794e713d0612043a1364 1 parent d54ec96
Rajan Agaskar authored July 31, 2012
3  Gemfile
... ...
@@ -1,9 +1,6 @@
1 1
 source "http://rubygems.org"
2 2
 gemspec
3 3
 
4  
-#bundle fails on the rspec gemspec requirement without this line
5  
-gem 'rspec', '< 2.11'
6  
-
7 4
 unless ENV["TRAVIS"]
8 5
   group :debug do
9 6
     gem 'debugger'
2  jasmine.gemspec
@@ -68,6 +68,6 @@ Gem::Specification.new do |s|
68 68
 
69 69
   s.add_dependency 'jasmine-core', ">= 1.2.0"
70 70
   s.add_dependency 'rack', '~> 1.0'
71  
-  s.add_dependency 'rspec', '>= 1.3.1', '< 2.11.0'
  71
+  s.add_dependency 'rspec', '>= 1.3.1'
72 72
   s.add_dependency 'selenium-webdriver', '>= 0.1.3'
73 73
 end
34  lib/jasmine/rspec_formatter.rb
@@ -9,24 +9,22 @@ def format_results(results)
9 9
     end
10 10
 
11 11
     def declare_suites(suites)
12  
-      me = self
13 12
       suites.each do |suite|
14  
-        declare_suite(self, suite)
  13
+        #empty block for rspec 1
  14
+        group = example_group(suite["name"]) {}
  15
+        process_children(group, suite["children"])
15 16
       end
16 17
     end
17 18
 
18  
-    def declare_suite(parent, suite)
19  
-      me = self
20  
-      parent.describe suite["name"] do
21  
-        suite["children"].each do |suite_or_spec|
22  
-          type = suite_or_spec["type"]
23  
-          if type == "suite"
24  
-            me.declare_suite(self, suite_or_spec)
25  
-          elsif type == "spec"
26  
-            me.declare_spec(self, suite_or_spec)
27  
-          else
28  
-            raise "unknown type #{type} for #{suite_or_spec.inspect}"
29  
-          end
  19
+    def process_children(parent, children)
  20
+      children.each do |suite_or_spec|
  21
+        type = suite_or_spec["type"]
  22
+        if type == "suite"
  23
+          process_children(parent.describe(suite_or_spec["name"]), suite_or_spec["children"])
  24
+        elsif type == "spec"
  25
+          declare_spec(parent, suite_or_spec)
  26
+        else
  27
+          raise "unknown type #{type} for #{suite_or_spec.inspect}"
30 28
         end
31 29
       end
32 30
     end
@@ -77,6 +75,14 @@ def report_spec(spec_id)
77 75
 
78 76
     private
79 77
 
  78
+    def example_group(*args, &block)
  79
+      if Jasmine::Dependencies.rspec2?
  80
+        RSpec::Core::ExampleGroup.describe(*args, &block).register
  81
+      else
  82
+        Spec::Example::ExampleGroupFactory.create_example_group(*args, &block)
  83
+      end
  84
+    end
  85
+
80 86
     def results_for(spec_id)
81 87
       @results.for_spec_id(spec_id.to_s)
82 88
     end

0 notes on commit bcf23c3

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