@@ -102,13 +102,12 @@ later feature methods may depend on earlier feature methods having executed.
102102
103103=== IgnoreIf
104104
105- To ignore a feature method under certain conditions, annotate it with `spock.lang.IgnoreIf`,
105+ To ignore a feature method or specification under certain conditions, annotate it with `spock.lang.IgnoreIf`,
106106followed by a predicate:
107107
108- [source,groovy]
108+ [source,groovy,indent=0 ]
109109----
110- @IgnoreIf({ System.getProperty("os.name").contains("windows") })
111- def "I'll run everywhere but on Windows"() { ... }
110+ include::{sourcedir}/extension/IgnoreIfDocSpec.groovy[tag=example-a]
112111----
113112
114113To make predicates easier to read and write, the following properties are available inside the closure:
@@ -124,10 +123,17 @@ To make predicates easier to read and write, the following properties are availa
124123
125124Using the `os` property, the previous example can be rewritten as:
126125
127- [source,groovy]
126+ [source,groovy,indent=0 ]
128127----
129- @IgnoreIf({ os.windows })
130- def "I'll run everywhere but on Windows"() { ... }
128+ include::{sourcedir}/extension/IgnoreIfDocSpec.groovy[tag=example-b]
129+ ----
130+
131+ If multiple `@IgnoreIf` annotations are present, they are effectively combined with a logical "or".
132+ The annotated element is skipped if any of the conditions evaluates to `true`:
133+
134+ [source,groovy,indent=0]
135+ ----
136+ include::{sourcedir}/extension/IgnoreIfDocSpec.groovy[tag=example-c]
131137----
132138
133139Care should be taken when ignoring feature methods in a spec class annotated with `spock.lang.Stepwise` since
@@ -137,10 +143,9 @@ To use IDE support like code completion, you can also use the argument to the cl
137143`org.spockframework.runtime.extension.builtin.PreconditionContext`. This enables the IDE with type information
138144which is not available otherwise:
139145
140- [source,groovy]
146+ [source,groovy,indent=0 ]
141147----
142- @IgnoreIf({ PreconditionContext it -> it.os.windows })
143- def "I'll run everywhere but on Windows"() { ... }
148+ include::{sourcedir}/extension/IgnoreIfDocSpec.groovy[tag=example-d]
144149----
145150
146151If applied to a data driven feature, the closure can also access the data variables.
0 commit comments