Skip to content
Browse files

Excluded the server name from being matched for VCR requests. Tests s…

…hould now pass in Travis...
  • Loading branch information...
1 parent 15e4fac commit fe938ad56630a3dc488985fd314adb3f4e30b50a @visoft committed
View
2 features/basic_auth.feature
@@ -12,7 +12,7 @@ Scenario: Entity should fill values on protected resource
Given I call "AddToCategories" on the service with a new "Category" object with Name: "Auth Test Category"
And I save changes
And I call "Categories" on the service with args: "1"
- When I run the query
+ When I run the query within a cassette named "basic_auth_protected_resource"
Then the method "Id" on the first result should equal: "1"
And the method "Name" on the first result should equal: "Auth Test Category"
View
57 features/cassettes/basic_auth_protected_resource.yml
@@ -0,0 +1,57 @@
+---
+http_interactions:
+- request:
+ method: get
+ uri: http://admin:passwd@win7dev:8989/SampleService/BasicAuth/RubyOData.svc/Categories(1)
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers:
+ Accept:
+ - ! '*/*; q=0.5, application/xml'
+ Accept-Encoding:
+ - gzip, deflate
+ User-Agent:
+ - Ruby
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ Cache-Control:
+ - no-cache
+ Content-Length:
+ - '1270'
+ Content-Type:
+ - application/atom+xml;type=entry;charset=utf-8
+ Server:
+ - Microsoft-IIS/7.5
+ Set-Cookie:
+ - ASP.NET_SessionId=zpifmralioi4qiwd0lg0uqcq; path=/; HttpOnly
+ X-Content-Type-Options:
+ - nosniff
+ Dataserviceversion:
+ - 1.0;
+ X-Aspnet-Version:
+ - 4.0.30319
+ X-Powered-By:
+ - ASP.NET
+ Date:
+ - Sat, 11 Aug 2012 21:36:29 GMT
+ body:
+ encoding: US-ASCII
+ string: <?xml version="1.0" encoding="utf-8"?><entry xml:base="http://win7dev:8989/SampleService/BasicAuth/RubyOData.svc/"
+ xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
+ xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss"
+ xmlns:gml="http://www.opengis.net/gml"><id>http://win7dev:8989/SampleService/BasicAuth/RubyOData.svc/Categories(1)</id><category
+ term="RubyODataService.Category" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"
+ /><link rel="edit" title="Category" href="Categories(1)" /><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Products"
+ type="application/atom+xml;type=feed" title="Products" href="Categories(1)/Products"
+ /><title /><updated>2012-08-11T21:36:30Z</updated><author><name /></author><content
+ type="application/xml"><m:properties><d:Id m:type="Edm.Int32">1</d:Id><d:Name>Auth
+ Test Category</d:Name><d:AuditFields m:type="RubyODataService.AuditFields"><d:CreateDate
+ m:type="Edm.DateTime">2012-08-11T21:36:30.453</d:CreateDate><d:ModifiedDate
+ m:type="Edm.DateTime">2012-08-11T21:36:30.453</d:ModifiedDate><d:CreatedBy>Machinist</d:CreatedBy></d:AuditFields></m:properties></content></entry>
+ http_version: !!null
+ recorded_at: Sat, 11 Aug 2012 21:36:30 GMT
+recorded_with: VCR 2.2.4
View
6 features/support/vcr.rb
@@ -1,9 +1,13 @@
require "vcr"
+require File.expand_path("../../../spec/support/sample_service_matcher", __FILE__)
VCR.configure do |c|
c.hook_into :webmock
c.cassette_library_dir = "features/cassettes"
- c.default_cassette_options = { :record => :none }
+ c.default_cassette_options = {
+ :record => :none,
+ :match_requests_on => [:method, OData::Support::SampleServiceMatcher]
+ }
end
VCR.cucumber_tags do |t|
View
15 spec/support/sample_service_matcher.rb
@@ -0,0 +1,15 @@
+require 'uri'
+
+module OData
+ module Support
+ class SampleServiceMatcher
+ def self.call(req1, req2)
+ regexp = /^(https?:\/\/(?:[^@]*@)?)[^:]*(:\d+\/.*$)/i
+ request1 = req1.uri.match(regexp)
+ request2 = req2.uri.match(regexp)
+
+ (request1[1] == request2[1]) && (request1[2] == request2[2])
+ end
+ end
+ end
+end

0 comments on commit fe938ad

Please sign in to comment.
Something went wrong with that request. Please try again.