My tests were failing with this error:
ERROR (0:00:00.728) test_find_youtube_video_by_url
undefined method `at' for nil:NilClass
@ /Users/tom/.rvm/gems/ruby-1.9.3-p125@elocal/gems/youtube_it-2.1.7/lib/youtube_it/parser.rb:380:in `parse_entry'
test/unit/video_handlers/youtube_video_test.rb:4:in `block in <class:YoutubeVideoTest>'
That is actually hiding the real error, which is:
An HTTP request has been made that VCR does not know how to handle:
There is currently no cassette in use. There are a few ways
you can configure VCR to handle this request:
* If you want VCR to record this request and play it back during future test
runs, you should wrap your test (or this portion of your test) in a
`VCR.use_cassette` block .
* If you only want VCR to handle requests made while a cassette is in use,
configure `allow_http_connections_when_no_cassette = true`. VCR will
ignore this request since it is made when there is no cassette .
* If you want VCR to ignore this request (and others like it), you can
set an `ignore_request` callback .
It should show the VCR error, as it took a bit of confusion and debugging to figure out where this was happening. I believe the problem code is the following:
module Parser #:nodoc:
class FeedParser #:nodoc:
@content = (content =~ URI::regexp(%w(http https)) ? open(content).read : content)
rescue OpenURI::HTTPError => e
@content = content
We can't be rescuing VCR errors here. Instead, we should be using a begin/rescue/end and rescuing OpenURI::HTTPError.
mmmm what version of ruby do you have? for me and travis works perfect
I can confirm this error, ruby 1.9.3p194.
It occurs when you have a cassette already recorded and then amend or add to the test which causes VCR to raise an exception describing how to handle the situation.
I can supply a simple patch if you like?
We are using 1.9.3-p125, but are considering upgrading to the latest. I'll let you guys know if this continues after we upgrade.