title: Using spock to test a complicated JSON string condition is never satisified
body: <pre><code>org.spockframework:spock-core:0.7-groovy-2.0
  Gradle 1.12
  Groovy 1.8.6
  </code></pre>
  
  <p>Hello,</p>
  
  <p>I have a function that will return a JSON string. And I want to test that my function correctly creates the JSON format. However, I am having a problem with maybe some escape characters as the test always fails.</p>
  
  <p>This is the correct JSON format I am expecting and testing against:</p>
  
  <pre><code>{"function":"verifyEmail","parameters":[{"email_pwd":"password","session_id":"S1234","snapz_id":"T1234","email":"a@hotmail.com","access_token":"abcd"}]}
  </code></pre>
  
  <p>However, setting up the condition is proving difficult because of the <code>double quotes</code> and the <code>[ ]</code> characters. I have tried to escape them. </p>
  
  <p>This is the function:</p>
  
  <pre><code>def 'Parse the string to create JSON object'() {
      setup:
      def requestFactory = new RequestFactory();
      def snapzJSON = requestFactory.createWSRequest(FunctionReq.VERIFY_EMAIL, accessToken, sessionId, snapzId, email, emailPwd)
  
      expect: 'Correctly formats JSON string'
      System.out.println("SPOCK TEST: " + snapzJSON.createJSONRequest())
      snapzJSON.createJSONRequest()  == '{\"function\":\"verifyEmail\",\"parameters\":\\[{\"email_pwd\":\"password\",\"session_id\":\"S1234\",\"snapz_id\":\"T1234\",\"email\":\"a@hotmail.com\",\"access_token\":\"abcd\"}\\]}'        
  }
  </code></pre>
  
  <p>And this is the result:</p>
  
  <pre><code>Condition not satisfied:
  
  snapzJSON.createJSONRequest()  == '{\"function\":\"verifyEmail\",\"parameters\":\\[{\"email_pwd\":\"password\",\"session_id\":\"S1234\",\"snapz_id\":\"T1234\",\"email\":\"a@hotmail.com\",\"access_token\":\"abcd\"}\\]}'
  |         |                    |
  |         |                    false
  |         [parameters:[[session_id:S1234, snapz_id:T1234, email:a@hotmail.com, email_pwd:password, access_token:abcd]], function:verifyEmail]
  abcd S1234 T1234 a@hotmail.com password
  </code></pre>
  
  <p>Is there an easier way of doing this?</p>
  
  <p>Many thanks for any suggestions,</p>
  
  <p>Some additional output from test results:</p>
  
  <pre><code>jsonObject: {"parameters":[{"session_id":"S1234","snapz_id":"T1234","email":"a@hotmail.com","email_pwd":"password","access_token":"abcd"}],"function":"verifyEmail"}
  SPOCK TEST: [parameters:[[session_id:S1234, snapz_id:T1234, email:a@hotmail.com, email_pwd:password, access_token:abcd]], function:verifyEmail]
  </code></pre>