You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2014/06/18 19:53:38 UTC

git commit: Convert Spock to TestNG

Repository: tapestry-5
Updated Branches:
  refs/heads/master a08fd3bd1 -> 09985ff63


Convert Spock to TestNG


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/09985ff6
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/09985ff6
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/09985ff6

Branch: refs/heads/master
Commit: 09985ff63a24c0a8cc764b07fe693ea32199dd60
Parents: a08fd3b
Author: Jochen Kemnade <jk...@apache.org>
Authored: Wed Jun 18 19:52:13 2014 +0200
Committer: Jochen Kemnade <jk...@apache.org>
Committed: Wed Jun 18 19:52:13 2014 +0200

----------------------------------------------------------------------
 .../services/javascript/AMDWrapperSpec.groovy   | 65 --------------------
 .../services/javascript/AMDWrapperTest.groovy   | 64 +++++++++++++++++++
 2 files changed, 64 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/09985ff6/tapestry-core/src/test/groovy/org/apache/tapestry5/services/javascript/AMDWrapperSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/services/javascript/AMDWrapperSpec.groovy b/tapestry-core/src/test/groovy/org/apache/tapestry5/services/javascript/AMDWrapperSpec.groovy
deleted file mode 100644
index 802f932..0000000
--- a/tapestry-core/src/test/groovy/org/apache/tapestry5/services/javascript/AMDWrapperSpec.groovy
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.apache.tapestry5.services.javascript
-
-import org.apache.tapestry5.ioc.Resource
-
-import spock.lang.Specification
-
-class AMDWrapperSpec extends Specification {
-
-    def "AMD wrapper without dependencies"(){
-        setup:
-        Resource resource = Mock()
-        when:
-        def wrapper = new AMDWrapper(resource)
-        def moduleConfiguration = wrapper.asJavaScriptModuleConfiguration()
-        then:
-        !moduleConfiguration.needsConfiguration
-        when:
-        def amdModuleContent = moduleConfiguration.resource.openStream().text
-        then:
-        amdModuleContent ==
-                """define([], function(){
-alert('Hello World!');
-});"""
-        1 * resource.openStream() >> new ByteArrayInputStream("alert('Hello World!');".bytes)
-    }
-
-    def "AMD wrapper with named dependencies"(){
-        setup:
-        Resource resource = Mock()
-        when:
-        def wrapper = new AMDWrapper(resource)
-        wrapper.require("jquery", '$')
-        def moduleConfiguration = wrapper.asJavaScriptModuleConfiguration()
-        then:
-        !moduleConfiguration.needsConfiguration
-        when:
-        def amdModuleContent = moduleConfiguration.resource.openStream().text
-        then:
-        amdModuleContent ==
-                '''define(["jquery"], function($){
-$("body").css("background-color", "pink");
-});'''
-        1 * resource.openStream() >> new ByteArrayInputStream('$("body").css("background-color", "pink");'.bytes)
-    }
-
-    def "AMD wrapper with return expression"(){
-        setup:
-        Resource resource = Mock()
-        when:
-        def wrapper = new AMDWrapper(resource)
-        wrapper.setReturnExpression("myImportantVar")
-        def moduleConfiguration = wrapper.asJavaScriptModuleConfiguration()
-        then:
-        !moduleConfiguration.needsConfiguration
-        when:
-        def amdModuleContent = moduleConfiguration.resource.openStream().text
-        then:
-        amdModuleContent ==
-                '''define([], function(){
-var myImportantVar = 42;
-return myImportantVar;
-});'''
-        1 * resource.openStream() >> new ByteArrayInputStream('var myImportantVar = 42;'.bytes)
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/09985ff6/tapestry-core/src/test/groovy/org/apache/tapestry5/services/javascript/AMDWrapperTest.groovy
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/services/javascript/AMDWrapperTest.groovy b/tapestry-core/src/test/groovy/org/apache/tapestry5/services/javascript/AMDWrapperTest.groovy
new file mode 100644
index 0000000..bbf328e
--- /dev/null
+++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/services/javascript/AMDWrapperTest.groovy
@@ -0,0 +1,64 @@
+package org.apache.tapestry5.services.javascript
+
+import org.apache.tapestry5.ioc.Resource
+import org.apache.tapestry5.test.TapestryTestCase
+import org.testng.annotations.Test;
+
+class AMDWrapperTest extends TapestryTestCase {
+
+    @Test
+    void AMDwrapper_without_dependencies(){
+        Resource resource = newMock(Resource)
+        expect(resource.openStream()).andReturn(new ByteArrayInputStream("alert('Hello World!');".bytes))
+
+        replay()
+
+        def wrapper = new AMDWrapper(resource)
+
+        def moduleConfiguration = wrapper.asJavaScriptModuleConfiguration()
+
+        assertFalse(moduleConfiguration.needsConfiguration)
+        assertEquals(moduleConfiguration.resource.openStream().text,
+                """define([], function(){
+alert('Hello World!');
+});""")
+    }
+
+    @Test
+    void AMDWrapper_with_named_dependencies(){
+        Resource resource = newMock(Resource)
+        expect(resource.openStream()).andReturn(new ByteArrayInputStream('$("body").css("background-color", "pink");'.bytes))
+
+        replay()
+
+        def wrapper = new AMDWrapper(resource)
+        wrapper.require("jquery", '$')
+
+        def moduleConfiguration = wrapper.asJavaScriptModuleConfiguration()
+        assertFalse(moduleConfiguration.needsConfiguration)
+        assertEquals(moduleConfiguration.resource.openStream().text,
+                '''define(["jquery"], function($){
+$("body").css("background-color", "pink");
+});''')
+
+    }
+
+    @Test
+    void AMDWrapper_with_return_expression(){
+        Resource resource = newMock(Resource)
+        expect(resource.openStream()).andReturn(new ByteArrayInputStream('var myImportantVar = 42;'.bytes))
+
+        replay()
+
+        def wrapper = new AMDWrapper(resource)
+        wrapper.setReturnExpression("myImportantVar")
+
+        def moduleConfiguration = wrapper.asJavaScriptModuleConfiguration()
+        assertFalse(moduleConfiguration.needsConfiguration)
+        assertEquals(moduleConfiguration.resource.openStream().text,
+                '''define([], function(){
+var myImportantVar = 42;
+return myImportantVar;
+});''')
+    }
+}