Comments (14)
Okay, trying to add some failing tests to figure out what's triggering the bug in my case, I notice that if your describe starts with a capital letter, it does something slightly different than expected by existing tests:
describe 'OneWord', :vcr do
it 'uses a cassette for any examples' do
(VCR.current_cassette.name.split('/')).must_equal([
'MinitestVcr::Spec',
'OneWord',
'uses a cassette for any examples'
])
end
end
1) Failure:
MinitestVcr::Spec::OneWord::vcr#test_0001_uses a cassette for any examples [/Users/jrochkind/code/minitest-vcr/test/minitest-vcr/spec_test.rb:27]:
--- expected
+++ actual
@@ -1 +1 @@
-["MinitestVcr::Spec", "OneWord", "uses a cassette for any examples"]
+["MinitestVcr::Spec::OneWord", "uses a cassette for any examples"]
Is it expected that it jams the one word onto the end of the first component. It seems to only happen when it begins with a capital letter. Not sure if this is related to my bug or not.
from minitest-vcr.
Bah, that's probably not it.
Something really weird is going on, which looks possibly somehow related to using VCR's filter_sensitive_data functionality, although that doesn't make a lot of sense.
I'm also in some cases, even without filter_sensitive_data, getting crazy extra-long path names for yml cassettes, that include the names of other unrelated tests in them.
Can't quite reproduce in minitest test spec; could it somehow be related to using WebMock, as I am?
I guess I'll go off into the debugger to try and figure it out.
from minitest-vcr.
In my own app, I have now managed to isolate and reproduce the case where VCR.current_cassette.name is nil, and thus the cassette ends up being called just ".yml".
I haven't managed to reproduce it yet in minitest-vcr's own tests; maybe my own unique dependencies? Trying to figure it out.
from minitest-vcr.
Okay! It's when I try to pass a :tag to VCR. Drop this file into minitest-vcr master, it demonstrates:
require 'helper'
MinitestVcr::Spec.configure!
describe "with tag metadata", :vcr => {:tag => :bd_finditem} do
before do
conn = Faraday.new
@response = conn.get 'http://example.com'
end
it "uses appropraite cassette name" do
assert ! VCR.current_cassette.nil?, "No current cassette"
assert ! VCR.current_cassette.name.nil?, "No current cassette name"
if VCR.current_cassette.name
(VCR.current_cassette.name.split('/')).must_equal([
'with tag metadata',
'uses appropraite cassette name'
])
end
end
end
I'll see if I can debug it and PR it, but any advice/help welcome!
from minitest-vcr.
Good stuff Jonathan! Thanks for the debugging. I will give this a look soon.
from minitest-vcr.
Okay!
So in typical cases like it "example", :vcr
, the example.class.name
that gets passed to minitest-vcr here looks like "name of example::vcr"
.
However, if you pass a tag (or maybe any extra arguments at all?) to vcr, like:
it "example", :vcr => {:tag => :foo}
Then for some reason the example.class.name
is missing the suffix, and just looks like "name of example"
.
The scan regexp then doesn't scan it properly, and ends up with an empty class_name
.
Not entirely sure the right way to fix it. I can make the scan regex more complicated, but I'm not sure I understand what's going on.
I also wonder if a self-check should be done there, and raise right there if the class_name
extracted is nil or empty string, rather than passing it on to create a casette name like just .yml
.
There's other weird stuff going on in my case too, but I'm hoping once we fix this one, it'll fix the others too!
from minitest-vcr.
or wiat, maybe not. i'm so confused. i'm hoping my example reproduces for you, and you can help!
from minitest-vcr.
yeah, can't manage to fix this in a way that doesn't break other things; I don't entirely understand what's going on or what the intention of your code is, def need your help! In the meantime, I'll avoid using :tag, but I kind of need it!
from minitest-vcr.
I am busy for the next few hours but hopefully I will be able to jump in figure out this tag thing later today. I do not use tags in requests so it might help to tell me an example use-case for tagging tests.
from minitest-vcr.
cool! I won't return to it again until Monday probably.
It's not just tags, it's actually any metadata you pass to VCR. This also breaks it:
it "something", :vcr => { :match_requests_on => [:body] }
And while I can do without tags for now, I can't do without that, I need it for my tests to work.
from minitest-vcr.
These are options you pass to VCR -- you aren't tagging tests exactly you are tagging VCR cassettes, actually. Or passing other options to VCR.
The use case for passing a :tag argument to VCR is so you can apply other VCR hooks to only VCR cassettes with certain tags: https://www.relishapp.com/vcr/vcr/v/1-6-0/docs/configuration/hooks
I use it for applying certain VCR filter_sensitive_data operations to only certain requests.
But the bug is not just triggered by the VCR :tag option, but by any option you pass to VCR at all. For instance in my above example, :match_requests_on => [:body]. I think the use case for that, and various other VCR options, is pretty clear, but I can explain or point to the parts of VCR documentation that do, if you need.
from minitest-vcr.
Thanks for looking into this. The issue was the regex was scanning expecting a class as the first describe (i.e. Some::Class). It now works with a string description. Closed by #14
from minitest-vcr.
@jrochkind Thanks for the rake release BTW. v1.0.1 is cut.
from minitest-vcr.
Thanks very much!
from minitest-vcr.
Related Issues (9)
- Thanks! release? HOT 1
- VCR cassette in 'before' block? HOT 1
- inconsistent cassette naming when VCR options and nested describe HOT 10
- Adding 'minitest-vcr' to Gemfile brakes my test setup HOT 4
- support vcr 3.0 HOT 2
- Readme unclear, Does this work with minitest::unit? HOT 3
- There can be only one gem that calls #before or #after... HOT 6
- uninitialized constant MiniTest (NameError) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from minitest-vcr.