From 118dd8e04fcd253d740bfc615a82fb00cebf55c8 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Mon, 10 Oct 2016 14:09:02 +0200 Subject: [PATCH] Fixing the tests for Windows --- .../stubrunner/ContractDownloaderSpec.groovy | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/ContractDownloaderSpec.groovy b/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/ContractDownloaderSpec.groovy index 89ee9e369a..36e8d31154 100644 --- a/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/ContractDownloaderSpec.groovy +++ b/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/ContractDownloaderSpec.groovy @@ -9,11 +9,12 @@ class ContractDownloaderSpec extends Specification { StubDownloader stubDownloader = Stub() StubConfiguration stubConfiguration = new StubConfiguration('') - File file = new File('/some/path/to/somewhere') + + File file = new File(File.separator + ['some','path','to','somewhere'].join(File.separator)) def 'should set inclusion pattern on config when path pattern was explicitly provided with a separator at the beginning'() { given: - String contractPath = '/a/b/c/d' + String contractPath = File.separator + ['a','b','c','d'].join(File.separator) ContractDownloader contractDownloader = new ContractDownloader(stubDownloader, stubConfiguration, contractPath, '', '') ContractVerifierConfigProperties properties = new ContractVerifierConfigProperties() @@ -22,12 +23,13 @@ class ContractDownloaderSpec extends Specification { when: contractDownloader.unpackedDownloadedContracts(properties) then: - properties.includedContracts == '^/some/path/to/somewhere/a/b/c/d.*$' + + properties.includedContracts == fileSeparated('^/some/path/to/somewhere/a/b/c/d.*$') } def 'should set inclusion pattern on config when path pattern was explicitly provided without a separator at the beginning'() { given: - String contractPath = 'a/b/c/d' + String contractPath = fileSeparated('a/b/c/d') ContractDownloader contractDownloader = new ContractDownloader(stubDownloader, stubConfiguration, contractPath, '', '') ContractVerifierConfigProperties properties = new ContractVerifierConfigProperties() @@ -36,6 +38,10 @@ class ContractDownloaderSpec extends Specification { when: contractDownloader.unpackedDownloadedContracts(properties) then: - properties.includedContracts == '^/some/path/to/somewhere/a/b/c/d.*$' + properties.includedContracts == fileSeparated('^/some/path/to/somewhere/a/b/c/d.*$') + } + + private static String fileSeparated(String string) { + return string.replace('/', File.separator) } }