<commit_before>/* Copyright 2009 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package geb.spock

import spock.lang.*
import geb.test.util.GebSpecWithServer

@Stepwise
class GebReportingSpecSpec extends GebSpecWithServer {
	
	static responseText = """
		<html>
		<body>
			<div class="d1" id="d1">d1</div>
		</body>
		</html>
	"""
	
	static garbage = "asdfajsdifoamsdfoiawdncwonc"
	
	def setupSpec() {
		server.get = { req, res ->
			res.outputStream << responseText
		}
		
		def reportsDir = getClassReportDir()
		def firstOutputFile = getFirstOutputFile()
		
		if (!reportsDir.exists()) {
			assert reportsDir.mkdirs()
		}
		
		if (!firstOutputFile.exists()) {
			assert firstOutputFile.createNewFile()
		}
		
		// Put some jibberish in this file, so we can test
		// that it was actually removed by the reporting spec
		// setup() method.
		firstOutputFile << garbage
	}
	
	def getClassReportDir() {
		new File(getReportDir(), this.class.name.replace('.', '/'))
	}
	
	def getFirstOutputFile() {
		new File(getClassReportDir(), "1-a request is made.html")
	}
	
	def "a request is made"() {
		given:
		go("/") // make a request
	}
	
	def "a report should have been created with the response text"() {
		given:
		def report = getFirstOutputFile()
		expect:
		report.exists()
		!report.text.contains(garbage)
	}

	def "there should be a second report"() {
		expect:
		getClassReportDir().listFiles().any { it.name.startsWith("2") }
	}
	
}<commit_msg>Test fixes.<commit_after>/* Copyright 2009 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package geb.spock

import spock.lang.*
import geb.test.util.GebSpecWithServer

@Stepwise
class GebReportingSpecSpec extends GebSpecWithServer {
	
	static responseText = """
		<html>
		<body>
			<div class="d1" id="d1">d1</div>
		</body>
		</html>
	"""
	
	static garbage = "asdfajsdifoamsdfoiawdncwonc"
	
	def setupSpec() {
		server.get = { req, res ->
			res.outputStream << responseText
		}
		
		def reportsDir = getClassReportDir()
		def firstOutputFile = getFirstOutputFile()
		
		if (!reportsDir.exists()) {
			assert reportsDir.mkdirs()
		}
		
		if (!firstOutputFile.exists()) {
			assert firstOutputFile.createNewFile()
		}
		
		// Put some jibberish in this file, so we can test
		// that it was actually removed by the reporting spec
		// setup() method.
		firstOutputFile << garbage
	}
	
	def getClassReportDir() {
		new File(getReportDir(), this.class.name.replace('.', '/'))
	}
	
	def getFirstOutputFile() {
		new File(getClassReportDir(), "1-1-a request is made-end.html")
	}
	
	def "a request is made"() {
		given:
		go("/") // make a request
	}
	
	def "a report should have been created with the response text"() {
		given:
		def report = getFirstOutputFile()
		expect:
		report.exists()
		!report.text.contains(garbage)
	}

	def "there should be a second report"() {
		expect:
		getClassReportDir().listFiles().any { it.name.startsWith("2") }
	}
	
}
{'fraction_non_alphanumeric': 0.11425, 'fraction_numerical': 0.00675, 'mean_word_length': 3.5311438278595695, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3229318', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1216, 'n_words': 409}