diff --git a/docs/index.adoc b/docs/index.adoc index 67949c0..36b6fa6 100644 --- a/docs/index.adoc +++ b/docs/index.adoc @@ -70,7 +70,7 @@ dependencies { ---- include::../fixt/src/test/groovy/com/agorapulse/testing/fixt/FixtSpec.groovy[] ---- -<1> Declare `Fixt` rule for the specification class +<1> Declare `Fixt` rule for the specification <2> Read the content of the file as stream <3> Read the content of the file as text <4> Create `Fixt` for the specific class (`ReferenceClass`) diff --git a/fixt/src/main/groovy/com/agorapulse/testing/fixt/Fixt.java b/fixt/src/main/groovy/com/agorapulse/testing/fixt/Fixt.java index 0d2d0d6..bff603a 100644 --- a/fixt/src/main/groovy/com/agorapulse/testing/fixt/Fixt.java +++ b/fixt/src/main/groovy/com/agorapulse/testing/fixt/Fixt.java @@ -19,6 +19,15 @@ public class Fixt implements TestRule { private static final String TEST_RESOURCES_FOLDER_PROPERTY_NAME = "testresourcesfolder"; private static final String IGNORED_CHARACTERS = "[\\W_]"; + /** + * Creates new Fixt for the given object which might be a class. + * @param object the given object which might be class + * @return new Fixt for the given object + */ + public static Fixt create(Object object) { + return new Fixt(object instanceof Class ? (Class) object : object.getClass()); + } + /** * Creates new Fixt for the given class. * @param clazz the given class diff --git a/fixt/src/test/groovy/com/agorapulse/testing/fixt/FixtSpec.groovy b/fixt/src/test/groovy/com/agorapulse/testing/fixt/FixtSpec.groovy index 10e15f1..4f601fd 100644 --- a/fixt/src/test/groovy/com/agorapulse/testing/fixt/FixtSpec.groovy +++ b/fixt/src/test/groovy/com/agorapulse/testing/fixt/FixtSpec.groovy @@ -17,7 +17,7 @@ class FixtSpec extends Specification { TemporaryFolder tmp = new TemporaryFolder() @Rule - Fixt fixt = Fixt.create(FixtSpec) // <1> + Fixt fixt = Fixt.create(this) // <1> void 'reading existing files'() { expect: diff --git a/gradle.properties b/gradle.properties index ceac644..805a5cc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version = 0.1.2 +version = 0.1.3 groovyVersion = 2.5.4 junitVersion = 4.12 spockVersion = 1.2-groovy-2.5