Skip to content

Commit

Permalink
Fix compatibility with rspec 2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
ragaskar committed Jul 31, 2012
1 parent d54ec96 commit bcf23c3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
3 changes: 0 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion jasmine.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
34 changes: 20 additions & 14 deletions lib/jasmine/rspec_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bcf23c3

Please sign in to comment.