Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix compatibility with rspec 2.11

  • Loading branch information...
commit bcf23c3e69012e5e068b794e713d0612043a1364 1 parent d54ec96
@ragaskar ragaskar authored
Showing with 21 additions and 18 deletions.
  1. +0 −3  Gemfile
  2. +1 −1  jasmine.gemspec
  3. +20 −14 lib/jasmine/rspec_formatter.rb
View
3  Gemfile
@@ -1,9 +1,6 @@
source "http://rubygems.org"
gemspec
-#bundle fails on the rspec gemspec requirement without this line
-gem 'rspec', '< 2.11'
-
unless ENV["TRAVIS"]
group :debug do
gem 'debugger'
View
2  jasmine.gemspec
@@ -68,6 +68,6 @@ Gem::Specification.new do |s|
s.add_dependency 'jasmine-core', ">= 1.2.0"
s.add_dependency 'rack', '~> 1.0'
- s.add_dependency 'rspec', '>= 1.3.1', '< 2.11.0'
+ s.add_dependency 'rspec', '>= 1.3.1'
s.add_dependency 'selenium-webdriver', '>= 0.1.3'
end
View
34 lib/jasmine/rspec_formatter.rb
@@ -9,24 +9,22 @@ def format_results(results)
end
def declare_suites(suites)
- me = self
suites.each do |suite|
- declare_suite(self, suite)
+ #empty block for rspec 1
+ group = example_group(suite["name"]) {}
+ process_children(group, suite["children"])
end
end
- def declare_suite(parent, suite)
- me = self
- parent.describe suite["name"] do
- suite["children"].each do |suite_or_spec|
- type = suite_or_spec["type"]
- if type == "suite"
- me.declare_suite(self, suite_or_spec)
- elsif type == "spec"
- me.declare_spec(self, suite_or_spec)
- else
- raise "unknown type #{type} for #{suite_or_spec.inspect}"
- end
+ def process_children(parent, children)
+ children.each do |suite_or_spec|
+ type = suite_or_spec["type"]
+ if type == "suite"
+ process_children(parent.describe(suite_or_spec["name"]), suite_or_spec["children"])
+ elsif type == "spec"
+ declare_spec(parent, suite_or_spec)
+ else
+ raise "unknown type #{type} for #{suite_or_spec.inspect}"
end
end
end
@@ -77,6 +75,14 @@ def report_spec(spec_id)
private
+ def example_group(*args, &block)
+ if Jasmine::Dependencies.rspec2?
+ RSpec::Core::ExampleGroup.describe(*args, &block).register
+ else
+ Spec::Example::ExampleGroupFactory.create_example_group(*args, &block)
+ end
+ end
+
def results_for(spec_id)
@results.for_spec_id(spec_id.to_s)
end
Please sign in to comment.
Something went wrong with that request. Please try again.