New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate #use_vcr_cassette #224
Conversation
Sorry, having trouble attaching this PR to an existing issue. |
Thanks, @austenito, this looks great. One random thought...given that I noticed that we're getting the deprecation notice in VCR's spec suite now--can you think of a way to silence it? |
|
||
group_descriptions.compact.reverse.join('/') | ||
end | ||
include VCR::Deprecations::Macros |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think maybe the module should be VCR::Deprecations::RSpecMacros
so it's more clear that it's for RSpec.
Yeah the extended approach is better I think. They'll get the hint if they see the message once. Also, I noticed the builds are failing. What is the process for failing builds? I remember seeing something about failures for different versions. In any case, I'll also work on getting them passing. |
The build is failing due to an unreproducible failure on 1.9.3. It passes locally for me, but fails consistently on Travis. It even passed for me when I installed the travis vagrant VM and ran the build there. It'd be great if you (or anyone) could get the build green again, but don't sweat it if you can't. I'm going to get in touch with the travis guys about. BTW, here's a twitter conversation about it, in case that helps: |
@myronmarston I've updated the PR with the following changes
|
@austenito -- Much improved, thanks. A couple more thoughts:
|
I'm confused -- is this a refactor of the |
Yeah you're right. Having all of the deprecated code in one spot is the right move. Just to be clear, you want the deprecated code to be moved into
I'll take care of that. Sorry about the failures. I didn't check since the builds were failing :( It be great if the builds didn't have false failures. Hopefully that gets resolved soon.
I'll add that as well. It might be good to have some docs on how to deprecate modules. I can write that up if you see value in it. Then again, how often do things get deprecated? Probably not all that often. |
@ajsharp Just a deprecation. I'm not sure when it will go away completely. You can achieve the same effect as |
You won't need that
It's been resolved...vcr master is green now: https://travis-ci.org/vcr/vcr/builds/3462761
Yeah, I don't think it's terribly often, and I often take it on a case-by-case basis. Not sure if there's value in it yet. |
@ajsharp -- as @austenito said, this is just a deprecation for now. As per SemVer, this'll remain in all 2.x releases. If/when a VCR 3.0 ships, I would expect it to be removed (but I have no plans yet for a 3.0). I'm deprecating it because I think the rspec metadata integration is superior in every way. There are some gotchas related to the |
When moving |
@austenito -- this looks fantastic....except for the travis build failures :(. It's getting a weird error on 1.8.7: https://travis-ci.org/vcr/vcr/jobs/3525755/#L223 Do you want to take a look at that before I merge? |
Yes I'll investigate! I apologize for all the back and forth with Travis. On Dec 5, 2012, at 9:10 PM, Myron Marston notifications@github.com wrote: @austenito https://github.com/austenito -- this looks fantastic....except https://travis-ci.org/vcr/vcr/jobs/3525755/#L223 Do you want to take a look at that before I merge? — |
No need to apologize! The VCR travis build was consistently failing for a while, and that was my fault. |
- Fixes #212 - Moved macro to deprecations.rb - Move RSpec::Macros to deprecations - Add deprecated tag
Deprecate #use_vcr_cassette
@austenito -- Sorry about not merging until now. I wasn't notified that you had pushed more code and the build passed. In the future, you should add a comment when you push new code so I get notified. |
A couple of questions:
context "when the Company Admin is creating a Job Posting", :vcr do
it "displays a notification that the job posting was successfully created and advise the Company Admin to continue with the selected Distributions" do
# ... my test assertions
end
...
end Now, granted, I can most likely reword something like this--but that may not always be the case. What would you suggest in situations like this in which the |
You can either pass a cassette name to the context "when the Company Admin is creating a Job Posting", vcr: { cassette_name: "some cassette" } do
it "displays a notification that the job posting was successfully created and advise the Company Admin to continue with the selected Distributions" do
# ... my test assertions
end
...
end ...or wrap your code in |
No, so far as I can tell, you can't. There is one use case, quite useful for me, which the new syntax doesn't cover. Right now, I can do context 'some context' do
use_vcr_cassette
it 'has an example' { 1.should == 1 }
it 'has another example' { 2.should == 2 }
end This will use one common cassette ( By contrast, if I do context 'some context', :vcr do
# same specs as before
end then two cassettes will be created ( Sure, I could achieve a common cassette with the new syntax by doing I don't want this feature to go away or give me deprecation warnings. Am I missing something? Is this possible with the new syntax? |
@marnen -- while context 'some context' do
use_vcr_cassette
it "makes some http requests" do
make_some_requests
end
it "makes some other http requests" do
make_some_other_requests
end
end VCR is best used where one cassette == one unique sequence of requests. When you mix multiple sequences of requests in the same cassette, it causes problems and VCR's not really meant to work that way. I got lots of questions from users where they were having problems related to using If you want to use the metadata approach, it's easy to handroll your own. VCR's integration with RSpec isn't meant to cover all cases, just the 95% common case. Here's one way you could roll your own: shared_context "use group VCR cassette", :vcr_group_cassette do |options = {}|
cassette_name = metadata[:example_group].container_stack.reverse.map { |c| c[:description] }.join('/')
around(:each) { |ex| VCR.use_cassette(cassette_name, options, &ex) }
end
# use with:
describe MyClass, :vcr_group_cassette do
end
# or
describe MyClass do
include_context "use group VCR cassette", record: :new_episodes, other: :vcr_options
end |
I know that. I'm not using it that way. In the case I was talking about, every spec in the context is making the same HTTP requests, but different assertions are being made about them. I think this is a proper use of VCR and of Thanks for the code sample. I hadn't really known where to start looking to implement this myself. |
Yep. The way you are using it is fine. That doesn't change the fact that |
Yeah, I can understand that. I feel a lot better knowing that there's a way to implement it for those times when it is useful. Thanks. |
deprecations.rb