rspec-mocks: RSpec mocks 3.12 breaks test suites due to kwargs in incomprehensible manner

Subject of the issue

I have just sent several PR to fix test suites of Guard projects:

https://github.com/guard/guard/pull/986 https://github.com/guard/guard-livereload/pull/194

What is problematic is that RSpec breaks the test suite in incomprehensible way. E.g. the guard test suite failed like this:

$ rspec -rspec_helper spec
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
Randomized with seed 55878
..................................................................*....stub me: ENV[COLUMNS]!
Pending: (Failures listed here are expected and do not affect your suite's status)
  1) Guard::Internals::Scope#titles 
     # Not yet implemented
     # ./spec/lib/guard/internals/scope_spec.rb:93
Finished in 1.46 seconds (files took 0.68148 seconds to load)
72 examples, 0 failures, 1 pending
Randomized with seed 55878

which does not even look like failure, except the return code. Please note that there is not COLUMNS string in the whole guard code base.

The guard-livereload was failing in following way:

$ rspec spec
Run options: include {:focus=>false}
All examples were filtered out; ignoring {:focus=>false}
Randomized with seed 58149

... snip ...

FF....................
Failures:
  1) Guard::LiveReload#start creates reactor with given options
     Failure/Error: @reactor = Reactor.new(options)
     RuntimeError:
       CRITICAL: RUBYGEMS_ACTIVATION_MONITOR.owned?: before false -> after true
     # ./lib/guard/livereload.rb:32:in `start'
     # ./spec/lib/guard/livereload_spec.rb:144:in `block (3 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # RuntimeError:
     #   stub called for File.expand_path("/usr/share/gems/gems/http_parser.rb-0.6.0/lib/pp")
     #   ./spec/lib/guard/livereload_spec.rb:12:in `block (3 levels) in <top (required)>'
  2) Guard::LiveReload#start creates reactor with default options
     Failure/Error: fail "stub called for File.expand_path(#{args.map(&:inspect) * ','})"
     RuntimeError:
       stub called for File.expand_path("/usr/share/gems/gems/http_parser.rb-0.6.0/lib/pp")
     # ./spec/lib/guard/livereload_spec.rb:12:in `block (3 levels) in <top (required)>'
     # ./lib/guard/livereload.rb:32:in `start'
     # ./spec/lib/guard/livereload_spec.rb:130:in `block (3 levels) in <top (required)>'
Finished in 0.08103 seconds (files took 0.20378 seconds to load)
35 examples, 2 failures

This is frustrating, because if you check the fixes, they really fix the kwargs. One might say that Guard is using some unorthodox ways of stubbing some calls. But OTOH, it is not nice that it really is not obvious what is going on. And surprisingly, in both cases the error is related to loading/using pp.

I don’t know if there is anything actionable here. Maybe the pp could be preloaded or it would not need to be used at all. Maybe there is a way to release changes like this when they are more polished. Maybe you can distill some bits of this report into separate tickets. I leave it to your consideration and will not be super sad if you just nod and close the ticket 😃

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 27 (12 by maintainers)

Most upvoted comments

The guard-livereload fails here:

https://github.com/guard/guard-livereload/blob/75c2617c99ad6d000b899dbbe58b6d9aaff74227/spec/lib/guard/livereload_spec.rb#L11-L13

Again, there is abort. But the issue is that something is newly using File.expand_path during the evaluation of the test double. I have not digger deeper into this, once I was sure that fixing the test avoids this issue.

(re opened because the original poster has not got a sensible error output, I don’t think RSpec is at fault see my earlier reproduction but I’d like to hear from the orignal poster again before closing)

I’m trying to setup a branch on https://github.com/cfurrow/rspec-mocks-fail-example that changes rspec-mocks back to v3.11.1, but doing so has not given me the same failure I saw in my main repo. It fails the same way that rspec-mocks 3.12.0 is failing.

https://github.com/cfurrow/rspec-mocks-fail-example/compare/rspec-mocks-3.11.1?expand=1

I still only get one passing and one failing spec example, like I do in v3.12.0. Hmm.

By the way, @pirj, I appreciate your quick replies here. I was simply commenting initially help build a context of the possible bug that the original poster was seeing. I was hoping it may be enough to realize what recent change may have caused this. Thanks for sticking with it.