doesn't work with rspec 2 #7

Closed
mackuba opened this Issue Jul 2, 2010 · 13 comments

Projects

None yet

6 participants

@mackuba

Getting a deprecation warning:

*****************************************************************
DEPRECATION WARNING: you are using a deprecated constant that will
be removed from a future version of RSpec.

* Spec is deprecated.
* RSpec is the new top-level module in RSpec-2

And then an error:

/var/lib/hudson/.rvm/gems/ruby-1.9.2-preview3/gems/ci_reporter-1.6.2/lib/ci/reporter/rspec.rb:42:in `<module:Reporter>': uninitialized constant RSpec::Runner (NameError)
        from /var/lib/hudson/.rvm/gems/ruby-1.9.2-preview3/gems/ci_reporter-1.6.2/lib/ci/reporter/rspec.rb:21:in `<module:CI>'
        from /var/lib/hudson/.rvm/gems/ruby-1.9.2-preview3/gems/ci_reporter-1.6.2/lib/ci/reporter/rspec.rb:20:in `<top (required)>'
@nicksieger
ci-reporter member

Confirm. Will need to introduce new logic for RSpec 2.

@thomasjachmann

Is there any plan to release a beta compatible with rspec 2 beta? I've seen that netoisstools has changed rspec.rb for rspec 2 compatibility: http://github.com/netoisstools/ci_reporter/commit/918bd95f8297f4e59787deab91bacecf78172f61

@anagri

does not work with Rails 3.0.0 and RSpec 2.0.0.beta.3 Fails with message :

/home/userX/.rvm/gems/ruby-1.9.2-p0/gems/ci_reporter-1.6.2/lib/ci/reporter/rspec.rb:42:in <module:Reporter>': uninitialized constant RSpec::Runner (NameError)
from /home/userX/.rvm/gems/ruby-1.9.2-p0/gems/ci_reporter-1.6.2/lib/ci/reporter/rspec.rb:21:in
module:CI'
from /home/userX/.rvm/gems/ruby-1.9.2-p0/gems/ci_reporter-1.6.2/lib/ci/reporter/rspec.rb:20:in `'

@tylerkovacs

Here's a diff that makes it work with rspec 2.0. Nick, I'm sure there's a way to integrate this while maintaining backwards compatibility with the old rspec but I haven't looked into that.

diff --git a/lib/ci/reporter/rspec.rb b/lib/ci/reporter/rspec.rb
index e45a67a..aaec487 100644
--- a/lib/ci/reporter/rspec.rb
+++ b/lib/ci/reporter/rspec.rb
@@ -6,8 +6,8 @@ require 'ci/reporter/core'
 tried_gem = false
 begin
   require 'spec'
-  require 'spec/runner/formatter/progress_bar_formatter'
-  require 'spec/runner/formatter/specdoc_formatter'
+  require 'spec/core/formatters/progress_formatter'
+  require 'spec/core/formatters/base_formatter'
 rescue LoadError
   unless tried_gem
     tried_gem = true
@@ -39,17 +39,18 @@ module CI
     end

     # Custom +RSpec+ formatter used to hook into the spec runs and capture resu
-    class RSpec < Spec::Runner::Formatter::BaseFormatter
+    class RSpec < Spec::Core::Formatters::BaseFormatter
       attr_accessor :report_manager
       attr_accessor :formatter
       def initialize(*args)
         super
-        @formatter ||= Spec::Runner::Formatter::ProgressBarFormatter.new(*args)
+        @formatter ||= Spec::Core::Formatters::ProgressFormatter.new(*args)
         @report_manager = ReportManager.new("spec")
         @suite = nil
       end

       def start(spec_count)
+       @start = Time.now
         @formatter.start(spec_count)
       end

@@ -140,7 +141,7 @@ module CI

     class RSpecDoc < RSpec
       def initialize(*args)
-        @formatter = Spec::Runner::Formatter::SpecdocFormatter.new(*args)
+        @formatter = Spec::Core::Formatters::SpecdocFormatter.new(*args)
         super
       end
     end
@jfirebaugh

Apparently there's more to this than just fixing the requires and constant names. I haven't been able to get any of the half-dozen or so forks to work properly. Eagerly awaiting official support.

@tylerkovacs

Yes, there were a few more things that needed to be fixed in order to get it running with rspec-rails 2.0.0.beta.19. I created a fork with the changes that work for me.

http://github.com/tylerkovacs/ci_reporter

The fork also includes some fixes from another user running beta22.

@jfirebaugh

Hi Tyler,

I tried your fork but got this error: http://gist.github.com/599530

@jfirebaugh

Looks like http://github.com/tylerkovacs/ci_reporter/commit/12d5760947fd50071e86f4b02d22f29a404e4380 resolves that.

Thanks Tyler, I recommend your fork for anyone else who needs RSpec 2 compatibility.

@tylerkovacs

Great, I'm glad it worked for you John.

@jfirebaugh

Aaaand... it broke again with RSpec 2 RC.

ci/reporter/rspec.rb:42: uninitialized constant RSpec::Core::Formatters (NameError)
@tylerkovacs

Thanks John, I just pushed a fix for rspec2 final.

@nicksieger
ci-reporter member

This is fixed in trunk and will go out in 1.6.3.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment