Closed dazza-codes closed 7 years ago
What would be the easiest solution on our side to fix this? (Ideally not depending on VCR gem)
In this gem: test whether VCR is loaded; if so, disable it when doing the post and then enable it again. It might look something like:
VCR.turn_off! if Object.const_defined?('VCR') && VCR.respond_to?(:turn_off!)
# push the coverage data
VCR.turn_on! if Object.const_defined?('VCR') && VCR.respond_to?(:turn_on!)
If that code change works, then the error should be avoided every time, regardless of VCR config changes. AFAIK, the VCR gem is always loaded as VCR
.
For documentation purposes, note that adding an ignore clause to the VCR config can avoid this error, e.g. the following options are working on the project that raised this error:
require 'vcr'
VCR.configure do |config|
# other config options
c.allow_http_connections_when_no_cassette = false
c.ignore_hosts 'api.codacy.com'
end
In the first example. Even if we do not require the gem we will be able to invoke a method on it?
Yes, there's nothing in that code that requires bundling the VCR gem. It just checks whether the VCR class (which has a constant name of 'VCR') is defined and, if it is, whether it responds to those VCR methods. Test it out to see whether it works without including the VCR gem, it should be OK.
We do not have any code using VCR. Are you able to test adding those two lines around https://github.com/codacy/ruby-codacy-coverage/blob/master/lib/codacy/client.rb#L26 locally and see if it works?
My only project using codacy currently contains VCR and could not run the test suite easily without it. If you do not have it, that's actually better, because it should not fail without VCR. (Passing the baton back to ya.)
@Ok. I just merged #25 and added a note in the README.
Will be released soon.
@darrenleeweber released as version 1.1.4
let me know if it works.
Updating from 1.1.1
to 1.1.4
failed in this travis build
Not sure why exactly, as no other changes were made. There seems to be a residual problem with WebMock that turning off VCR doesn't handle completely. Perhaps the troubleshooting tip in the README is sufficient (and revert this change)? I'm going to check one more thing first.
Shoot, this is not working as expected. It may be that the project using both VCR and codacy-coverage needs to take responsibility for this. The easiest solution is already in the README#troubleshooting section. So, recommending scrapping the VCR-toggle solution and releasing a 1.1.5
to replace the 1.1.4
(mistake). Sorry I didn't see that coming.
Ok. Just reverted the toggle. 1.1.5
.
Wrap the code coverage push so it turns off VCR exceptions, see
If you don't want to solve this issue at the level of code in this gem, just close this issue. There are options in VCR to ignore it and your documentation could make note of this as a possible problem when using VCR.
Here's a backtrace from a travis build: