Skip to content

Commit

Permalink
added groovy delegate for the FluentSpecificationAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlehansen committed Jan 18, 2017
1 parent 4e91c97 commit 675b0c1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
4 changes: 4 additions & 0 deletions fluentlenium-spock/pom.xml
Expand Up @@ -23,6 +23,10 @@
<artifactId>fluentlenium-junit</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
Expand Down
Expand Up @@ -2,35 +2,57 @@ package org.fluentlenium.adapter.spock

import org.fluentlenium.adapter.FluentTestRunnerAdapter
import org.fluentlenium.adapter.junit.FluentTestRule
import org.fluentlenium.core.domain.FluentList
import org.fluentlenium.core.domain.FluentWebElement
import org.fluentlenium.core.search.SearchFilter
import org.junit.ClassRule
import org.junit.Rule
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
import org.openqa.selenium.By
import org.openqa.selenium.WebElement
import spock.lang.Specification

class FluentSpecification extends Specification {

protected FluentSpecificationAdapter fl = new FluentSpecificationAdapter()
@Delegate
private FluentSpecificationAdapter fl = new FluentSpecificationAdapter()

FluentList<FluentWebElement> $(List<WebElement> rawElements) {
return fl.$(rawElements)
}

FluentList<FluentWebElement> $(By locator, SearchFilter... filters) {
return fl.$(locator, filters)
}

FluentList<FluentWebElement> $(String selector, SearchFilter... filters) {
return fl.$(selector, filters)
}

FluentList<FluentWebElement> $(SearchFilter... filters) {
return fl.$(filters)
}

@Rule
public TestRule watchman = new FluentTestRule(this) {
@Override
void starting(Description description) {
super.starting(description)
fl.specStarting(description.getTestClass(), description.getDisplayName())
specStarting(description.getTestClass(), description.getDisplayName())
}

@Override
void finished(Description description) {
super.finished(description)
fl.specFinished(description.getTestClass(), description.getDisplayName())
specFinished(description.getTestClass(), description.getDisplayName())
}

@Override
void failed(Throwable e, Description description) {
super.failed(e, description)
fl.specFailed(e, description.getTestClass(), description.getDisplayName())
specFailed(e, description.getTestClass(), description.getDisplayName())
}
}

Expand Down

0 comments on commit 675b0c1

Please sign in to comment.