Code Monkey home page Code Monkey logo

vcrurlconnection's People

Contributors

0xced avatar b-ray avatar dstnbrkr avatar epologee avatar haitaoli avatar kreeger avatar matthewryan avatar sjmadsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vcrurlconnection's Issues

VCRURLConnection doesn’t consider request headers and body

VCRURLConnection doesn’t properly record requests if they have the same method and same URL but different headers and/or body. This is obvious when looking at the source code since VCRRequestKey is based on the URI and method properties only.

An example where this behavior becomes problematic is when using the Range header. Say you first ask for range 0-123 then you ask for range 0-12345. The second request will never be recorded because it’s considered equal to the first one since it has the same URL and same method.

I plan to work on this issue but before I start I’d like to know what’s the status of #16 as these issues are slightly related.

Still Active?

Is this pod still active? If not is there something else that has taken it's place?

Match outgoing requests to existing recordings with a (slightly) different URI?

The API I'm writing tests for with VCR requires some URLs to contain a time-based string signature, that renders a different signature every x seconds. When using VCR to replay url connections with newer signatures, the recorded url does not match and the test will attempt a new, actual connection to the server. This makes a lot of the testing code useless.

http://somedomain.com/v1/some/path?sig=5b4971244ce968c77294aa436616333e

Is there a way in the current VCR to somehow have a recorded call match outgoing requests with a different signature, maybe by changing the "uri" attribute of the json to include wildcards of some sort?

If not, would you be interested in a PR that adds this feature to VCR?

P.S. I absolutely love your VCR pod by the way, great job!

[VCR stop] in the setup instructions

Why [VCR stop] is missing from following sample?

[VCR start];

NSString *path = @"http://example.com/example";
NSURL *url = [NSURL URLWithString:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];

// use either NSURLSession or NSURLConnection
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request];
[task resume];

// NSURLSession makes a real network request and VCRURLConnection
// will record the request/response pair.

// once async request is complete or application is ready to exit:
[VCR save:@"/path/to/cassette.json"]; // copy the output file into your project

Https session recording

It there any possibility for https session recording? Currently I can see only http requests are recorded.

Don't see expected error

Hi,

I recorded a response and play it back and expected a network error.
Apparently it could come from here:

// FIXME: store details of NSError in VCRResponse and populate here

Any chance to have it fixed?

JSON actually isn't pretty printed

I read the code, and I'm pretty sure you're doing it right with pretty print but the results don't match what I expect. Which is lines & tabbing. Instead it's a one liner.

screen shot 2013-09-26 at 15 57 02

VCRURLConnection can't handle testing multiple requests to the same endpoint

Hi @dstnbrkr!

First of all, thanks for the great tool, it helps us a lot mocking the network communication and therefore speeding up our integration tests. Unfortunately we cannot use VCRURLConnection like it is for all our tests, because we've discovered a non-trivial issue:

Problem

We're dispatching multiple requests to the same endpoint with different response expectations within one test case, but VCR always overwrites the responses with the latest one.

Recording example:

  1. verify that there are 0 issues: GET https://some.domain/issues - returns an array with 0 issues
  2. create an issue: POST https://some.domain/issues - returns issue id 123
  3. get all issues: GET https://some.domain/issues - returns an array with 1 issue
  4. delete the issue: DELETE https://some.domain/issues/123
  5. get all issues: GET https://some.domain/issues - returns an array with 0 issues

Replaying example:

  1. verify that there are 0 issues: GET https://some.domain/issues - returns an array with 0 issues - luckily this succeeds
  2. create an issue: POST https://some.domain/issues - returns issue id 123 - succeeds
  3. get all issues: GET https://some.domain/issues - returns an array with 0 issues - FAILS
  4. ...

We're getting the last recorded response for URL https://some.domain/issues every time in this test case.

Desired Behavior

Always get the correct response for the correct request, even when multiple requests to the same endpoint are dispatched.

Proposed Solution

To have a way to record and replay multiple requests to the same endpoint, i.e. instead of an array of VCRRecording objects, introduce a VCRRecordingSet holding a sorted array of VCRRecording objects as well as the main identifiers for the request (method and URL).

Matching the correct request could work similar to how it works right now with the only difference that we can't fetch the response from the VCRRecodingSetright away but would have to fetch it from the sorted array according to a certain index.

This would of course also mean that the VCRCassette or some other instance would need an additional state representing a request counter to read the VCRRecoding entries at the correct index from the sorted array.

Next Steps

I'll probably fork your implementation, if I find time and get the resources, to create a pull request with the suggested solution. But I'm not sure yet.

Have you thought about this issue already or did you specifically decide to go with the current solution for a special reason?

Request to fix three Xcode warnings

Hello,

There are 2 warnings Xcode currently produces about these lines:

+ (NSArray *)alternateSelectors {
    return @[ NSStringFromSelector(@selector(initWithRequest_VCR_:delegate:)),
              NSStringFromSelector(@selector(initWithRequest_VCR_:delegate:startImmediately:)) ];
}

Undeclared selector 'initWithRequest_VCR_:delegate:'
Undeclared selector 'initWithRequest_VCR_:delegate:startImmediately:)'

There is a warning Xcode produces about this line:

static void VCRStoreOriginalImplentation(SEL selector);

Unused function 'VCRStoreOriginalImplentation'

Thanks!

New release?

There has been quite a few commits since the 0.2.0 release. Are there any plans for a 0.2.1/ 0.3.0 with the latest changes?

Request to provide VCR class with 'isRecording/setRecording:' class-level property

Hello,

It would be great if VCRURLConnection could reflect its recording state, something very simple like having class-level property isRecording/setRecording:(BOOL)recording. It should be set/unset in +[VCR start] and +[VCR stop] methods respectively.

I would use it for things like:

if ([VCR isRecording]) {
    [VCR save:cassettePath];
}

Let me know, what you think about it.

Thanks.

Improve Tutorial and Setup Instructions

I was able to get things working just from the ease of using Cocoapods, but many users won't be as lucky. Also, the tutorial is very, very limited. It would be nice to have instructions for how to get this to work when used only within XCTest classes (which is kind of the point of the project). The example project does not include any tests written against the sample project. These tests would be great examples of how to use VCRURLConnection from a unit-test standpoint. I've been unable to find any outside tutorials online on how to use this successfully with Tests. I'm relatively new to testing, so I don't fully understand how everything works together and I'm sure many more users could benefit from this tool and better setup/tutorials. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.