Skip to content
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

VCR creates downcased folder names #68

Open
gmile opened this issue Jul 19, 2016 · 3 comments
Open

VCR creates downcased folder names #68

gmile opened this issue Jul 19, 2016 · 3 comments

Comments

@gmile
Copy link
Contributor

gmile commented Jul 19, 2016

I use the following naming for my cassettes:

use_cassette "Stripe.PlanTest/count" do

The above means I want to keep count.json inside Stripe.PlanTest folder, which is a name for my test module.

However VCR down cases the name of a folder to: stripe.plantest. Can this be changed to not perform downcase on write?

@gmile gmile changed the title VCR creates folders downcased VCR creates downcased folder names Jul 19, 2016
@parroty
Copy link
Owner

parroty commented Jul 20, 2016

Thanks for the comment. As you indicated, it's downcased and hasn't provided the way to maintain the original case.

https://github.com/parroty/exvcr/blob/v0.8.1/lib/exvcr/mock.ex#L116

If it doesn't break existing tests, it may be an option to provide some way (like providing a optional setting) to maintain the case.

@gmile
Copy link
Contributor Author

gmile commented Jul 21, 2016

@parroty the motivation behind this is that it's easy to run into problems with case sensitive / case insensitive file systems. I, for one, just did and lost a few hours yesterday debugging the issue with travis build.

Per travis docs:

The HFS+ file system on our OS X workers is case-insensitive (which is the default for OS X), and the files in a directory are returned sorted. On Linux, the file system is case-sensitive, and returns directory entries in the order they appear in the directory internally.

I ran exactly into this problem.

I got used to naming my cassette folders after test modules, e.g. Stripe.PlanTest/, MyLib.MyModuleTest/, etc. Now, given the FS differences and the fact that ExVCR downcases paths on the fly, I experienced the following:

  1. OS X: MyLib.MyModuleTest/my_cassette.json == mylib.mymoduletest/my_cassette.json, thus the cassettes are found and everything works,
  2. Linux: MyLib.MyModuleTest/my_cassette.json != mylib.mymoduletest/my_cassette.json, ExVCR doesn't find the cassette folder, and performs actual requests.

I think the best way to solve this would be to not downcase at all. However, making this optional is a good way resolve this in a short term (with default to perform downcase, e.g. no behaviour change). Yet in the long term I think a few additional things should happen:

  1. remove downcasing logic entirely in future release (after all, since the cassette names in tests are written manually by a human, most will expect that ExVCR resolves the exact file path specified in the use_cassette),
  2. in case of perform_downcase: true (or whatever this option would be called), add a warning that this flag will be removed in future release and the behaviour will change to always match the path.

Let me know if this makes sense.

@parroty
Copy link
Owner

parroty commented Jul 31, 2016

Thanks for the explanation and sorry being late to respond.
The explanation makes sense. In the short term, I prefer the option like perform_downcase: true though it maybe good to change at some point. I try to update the code, but pull request would great too :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants