Skip to content

Commit

Permalink
Merge pull request #6 from agorapulse/feature/fixt-create-from-object
Browse files Browse the repository at this point in the history
create Fixt from object
  • Loading branch information
musketyr authored Apr 5, 2019
2 parents e1d7775 + ada3cdb commit 35c9356
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
9 changes: 9 additions & 0 deletions fixt/src/main/groovy/com/agorapulse/testing/fixt/Fixt.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 35c9356

Please sign in to comment.