-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from vanta/master
Search potential collaborators fields in parent classes
- Loading branch information
Showing
2 changed files
with
60 additions
and
6 deletions.
There are no files selected for viewing
20 changes: 14 additions & 6 deletions
20
...ain/groovy/com/blogspot/toomuchcoding/spock/subjcollabs/SubjectsCollaboratorsUtils.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...groovy/com/blogspot/toomuchcoding/spock/subjcollabs/SubjectsCollaboratorsUtilsSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.blogspot.toomuchcoding.spock.subjcollabs | ||
|
||
import spock.lang.Specification | ||
|
||
|
||
class SubjectsCollaboratorsUtilsSpec extends Specification { | ||
|
||
def "should find collaborator fields in class with no parent"() { | ||
given: | ||
BaseSpec specClass = new BaseSpec() | ||
|
||
when: | ||
def fields = SubjectsCollaboratorsUtils.findAllDeclaredFieldsWithAnnotation(specClass, Collaborator) | ||
|
||
then: | ||
fields.size() == 1 | ||
fields[0].name == "field1" | ||
} | ||
|
||
def "should find collaborator fields in class with parent class"() { | ||
given: | ||
SpecClass specClass = new SpecClass() | ||
|
||
when: | ||
def fields = SubjectsCollaboratorsUtils.findAllDeclaredFieldsWithAnnotation(specClass, Collaborator) | ||
|
||
then: | ||
fields.size() == 2 | ||
fields.collect({it.getName()}).containsAll(["field1", "field3"]) | ||
} | ||
|
||
class BaseSpec { | ||
@Collaborator | ||
String field1 | ||
|
||
String field2 | ||
} | ||
|
||
class SpecClass extends BaseSpec { | ||
@Collaborator | ||
String field3 | ||
|
||
String field4 | ||
} | ||
|
||
} |