0

I have a Betamax test that I'm trying to configure to intercept calls to a web service that is using RESTClient. The calls to the web service aren't getting recorded. My test code looks like this:

@Betamax(tape = 'pending_transfer_success')
        void "test createPendingTransfer"() {
            BetamaxRoutePlanner.configure(restClient.client)
            BetamaxHttpsSupport.configure(restClient.client)

            when:
            Transfer transfer = service.createPendingTransfer(
                    beneficiaryFirstName, beneficiaryLastName, beneficiaryUserEmail, lineItemsIdsToTransfer)

            then:
            ...
    }

Inside the setup() method I'm configuring the RESTClient like so:

restClient = new RESTClient("${grailsApplication.config.acme.account.api.url}/")
service.restClient = restClient

The app is a Grails 2.2.3 app and the test is written using Spock. Any help explaining why the calls isn't being recorded would be greatly appreciated.

user1866924
  • 431
  • 5
  • 17
  • What Betamax version are you using? Do you have other tests that are recording successfully or is this the first one you've tried? Is this a unit or integration test? – Rob Fletcher Jun 19 '15 at 18:48
  • Betamax version is 1.1.2. We have another test that is using Betamax but it's not a Spock test (it extends GroovyTestCase). This test is a Spock unit test. – user1866924 Jun 19 '15 at 19:19
  • Hmm, Spock shouldn't be very different in the way it executes. Does the other test also refer to the same `service`? – Rob Fletcher Jun 19 '15 at 19:22
  • No, the other test is calling a different service and is using HTTPBuilder instead of RESTClient. Does it look like I configured RESTClient properly? – user1866924 Jun 19 '15 at 19:25
  • I noticed in your sample app you used a class called `co.freeside.betamax.ProxyConfiguration`. I don't see that. Has that been removed in the most recent version of Betamax? – user1866924 Jun 19 '15 at 19:31
  • Weird thing is the exact same code is working fine for a coworker. – user1866924 Jun 19 '15 at 20:54
  • It appears to be an issue when using localhost. When I switched to http://www.google.com/ the tape was written. Shouldn't setting `Recorder recorder = new Recorder(ignoreLocalhost: false)` allow localhost requests to be recorded? – user1866924 Jun 19 '15 at 22:40

0 Answers0