Skip to content

Commit

Permalink
Merge 0ef6709 into 159f54f
Browse files Browse the repository at this point in the history
  • Loading branch information
klieber committed Sep 14, 2016
2 parents 159f54f + 0ef6709 commit 6d2a93c
Show file tree
Hide file tree
Showing 29 changed files with 188 additions and 291 deletions.
1 change: 0 additions & 1 deletion .travis.yml
@@ -1,6 +1,5 @@
language: java
jdk:
- oraclejdk7
- oraclejdk8
before_install:
- "export DISPLAY=:99.0"
Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Expand Up @@ -3,7 +3,7 @@

<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<version>2.3-SNAPSHOT</version>
<version>3.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>jasmine-maven-plugin</name>
Expand Down Expand Up @@ -143,7 +143,7 @@
<htmlunit.version>2.19</htmlunit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.6</java.version>
<java.version>1.8</java.version>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.source>${java.version}</maven.compiler.source>
</properties>
Expand Down Expand Up @@ -272,9 +272,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
26 changes: 26 additions & 0 deletions src/test/java/com/github/searls/jasmine/HtmlAssertions.java
@@ -0,0 +1,26 @@
package com.github.searls.jasmine;

import org.assertj.core.api.AbstractCharSequenceAssert;

public class HtmlAssertions extends AbstractCharSequenceAssert<HtmlAssertions, String> {

public HtmlAssertions(String actual) {
super(actual, HtmlAssertions.class);
}

public HtmlAssertions containsLinkTagWithSource(String src) {
return this
.contains("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + src + "\"/>")
.describedAs("contains <link/> tag with src='" + src + "'");
}

public HtmlAssertions containsScriptTagWithSource(String src) {
return this
.contains("<script type=\"text/javascript\" src=\"" + src + "\"></script>")
.describedAs("contains <script/> tag with src='" + src + "'");
}

public static HtmlAssertions assertThat(String actual) {
return new HtmlAssertions(actual);
}
}
52 changes: 0 additions & 52 deletions src/test/java/com/github/searls/jasmine/Matchers.java

This file was deleted.

@@ -1,6 +1,7 @@
package com.github.searls.jasmine.coffee;

import org.apache.commons.lang3.StringEscapeUtils;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;

Expand All @@ -10,9 +11,6 @@
import java.util.Map;
import java.util.WeakHashMap;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;

public class CoffeeScriptIntegrationTest {

private static final String COFFEE =
Expand Down Expand Up @@ -47,7 +45,7 @@ public void before() throws Exception {
public void itCompiles() throws IOException {
String result = subject.compile(COFFEE);

assertThat(result, is(JAVASCRIPT));
Assertions.assertThat(result).isEqualTo(JAVASCRIPT);
}

@Test
Expand All @@ -58,7 +56,7 @@ public void itReliesOnTheCache() throws IOException {

String result = subject.compile(COFFEE);

assertThat(result, is(expected));
Assertions.assertThat(result).isEqualTo(expected);
}

private void injectFakeCache(Map<String, String> cacheMap) throws Exception {
Expand Down
@@ -1,47 +1,30 @@
package com.github.searls.jasmine.coffee;

import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
import org.junit.Test;

import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;

public class DetectsCoffeeTest {

private final DetectsCoffee subject = new DetectsCoffee();

@Test
public void whenAStringEndingInCoffeeThatsCoffee() {
assertThat("/some/path/to/pants.coffee", is(this.coffee()));
assertThat(subject.detect("/some/path/to/pants.coffee")).isTrue();
}

@Test
public void whenAStringDoesNotEndInCoffeeThatsNotCoffee() {
assertThat("/some/path/to/pants.cafe", is(not(this.coffee())));
assertThat(subject.detect("/some/path/to/pants.cafe")).isFalse();
}

@Test
public void whenCoffeeHasAQueryStringThatsCoffee() {
assertThat("/some/path/to/pants.coffee?stillCoffee=true", is(this.coffee()));
assertThat(subject.detect("/some/path/to/pants.coffee?stillCoffee=true")).isTrue();
}

@Test
public void whenJavaScriptHasACoffeeQueryThatsNotCoffee() {
assertThat("/some/path/to/pants.js?extension=lulz.coffee", is(not(this.coffee())));
}

private TypeSafeMatcher<String> coffee() {
return new TypeSafeMatcher<String>() {
@Override
public boolean matchesSafely(String path) {
return DetectsCoffeeTest.this.subject.detect(path);
}

@Override
public void describeTo(Description desc) {
}
};
assertThat(subject.detect("/some/path/to/pants.cafe")).isFalse();
}
}
Expand Up @@ -3,13 +3,13 @@
import com.gargoylesoftware.htmlunit.IncorrectnessListener;
import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
import com.gargoylesoftware.htmlunit.WebClient;
import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.openqa.selenium.remote.DesiredCapabilities;

import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
Expand All @@ -36,7 +36,7 @@ private void createDriver() {
public void enablesJavascript() {
createDriver();

assertTrue(driver.isJavascriptEnabled());
Assertions.assertThat(driver.isJavascriptEnabled()).isTrue();
}

private void modifyWebClient() {
Expand Down
Expand Up @@ -2,14 +2,12 @@

import com.github.searls.jasmine.mojo.Capability;
import com.google.common.collect.ImmutableList;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;


public class WebDriverFactoryTest {

Expand All @@ -24,29 +22,29 @@ public void setUp() {

@Test
public void defaultDriverIsCustomHtmlUnitDriver() throws Exception {
assertEquals(QuietHtmlUnitDriver.class, factory.createWebDriver().getClass());
Assertions.assertThat(factory.createWebDriver().getClass()).isEqualTo(QuietHtmlUnitDriver.class);
}

@Test
public void defaultDriverEnablesJavascript() throws Exception {
HtmlUnitDriver htmlUnitDriver = (HtmlUnitDriver) factory.createWebDriver();

assertTrue(htmlUnitDriver.isJavascriptEnabled());
Assertions.assertThat(htmlUnitDriver.isJavascriptEnabled()).isTrue();
}

@Test
public void customDriverIsCreatedWithDefaultConstructorIfNoCapabilitiesConstructorExists() throws Exception {
factory.setWebDriverClassName(CustomDriverWithDefaultConstructor.class.getName());

assertEquals(CustomDriverWithDefaultConstructor.class, factory.createWebDriver().getClass());
Assertions.assertThat(factory.createWebDriver().getClass()).isEqualTo(CustomDriverWithDefaultConstructor.class);
}


@Test
public void customDriverIsCreatedWithCapabilitiesIfConstructorExists() throws Exception {
factory.setWebDriverClassName(CustomDriverWithCapabilities.class.getName());

assertEquals(CustomDriverWithCapabilities.class, factory.createWebDriver().getClass());
Assertions.assertThat(factory.createWebDriver().getClass()).isEqualTo(CustomDriverWithCapabilities.class);
}

private Capabilities createWebDriverAndReturnCapabilities() throws Exception {
Expand All @@ -57,7 +55,7 @@ private Capabilities createWebDriverAndReturnCapabilities() throws Exception {

@Test
public void enablesJavascriptOnCustomDriver() throws Exception {
assertTrue(createWebDriverAndReturnCapabilities().isJavascriptEnabled());
Assertions.assertThat(createWebDriverAndReturnCapabilities().isJavascriptEnabled()).isTrue();
}

@Test
Expand All @@ -67,6 +65,6 @@ public void setsCapabilityFromMap() throws Exception {
capability.setValue("bar");
factory.setWebDriverCapabilities(ImmutableList.of(capability));

assertEquals("bar", createWebDriverAndReturnCapabilities().getCapability("foo"));
Assertions.assertThat(createWebDriverAndReturnCapabilities().getCapability("foo")).isEqualTo("bar");
}
}
@@ -1,10 +1,8 @@
package com.github.searls.jasmine.exception;

import org.assertj.core.api.Assertions;
import org.junit.Test;

import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertThat;

public class StringifiesStackTracesTest {

private StringifiesStackTraces subject = new StringifiesStackTraces();
Expand All @@ -17,7 +15,7 @@ public void stringifiesStackTrace() {

String result = subject.stringify(deep);

assertThat(result, containsString(deepest.getMessage()));
Assertions.assertThat(result).contains(deepest.getMessage());
}

}
@@ -1,11 +1,9 @@
package com.github.searls.jasmine.format;

import org.apache.commons.lang3.StringEscapeUtils;
import org.assertj.core.api.Assertions;
import org.junit.Test;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;


public class BuildsJavaScriptToWriteFailureHtmlTest {

Expand All @@ -16,17 +14,17 @@ public class BuildsJavaScriptToWriteFailureHtmlTest {

@Test
public void whenNothingIsPassedYouGetAnEmptyDiv() {
assertThat(subject.build(""), is(LEFT + RIGHT));
Assertions.assertThat(subject.build("")).isEqualTo(LEFT + RIGHT);
}

@Test
public void printsASimpleMessage() {
assertThat(subject.build("pants"), is(LEFT + "pants" + RIGHT));
Assertions.assertThat(subject.build("pants")).isEqualTo(LEFT + "pants" + RIGHT);
}

@Test
public void esacpesMessageString() {
assertThat(subject.build("<a>pant's</a>"), is(LEFT + "<a>pant\\'s<\\/a>" + RIGHT));
Assertions.assertThat(subject.build("<a>pant's</a>")).isEqualTo(LEFT + "<a>pant\\'s<\\/a>" + RIGHT);
}

}
@@ -1,12 +1,11 @@
package com.github.searls.jasmine.format;

import org.assertj.core.api.Assertions;
import org.junit.Test;

import java.util.HashSet;

import static java.util.Arrays.asList;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertThat;

public class FormatsScriptTagsTest {
private FormatsScriptTags subject = new FormatsScriptTags();
Expand All @@ -17,7 +16,7 @@ public void formatsOneScriptNicely() {

String result = subject.format(new HashSet<String>(asList(expected)));

assertThat(result, containsString(expectedScriptTagFormat(expected)));
Assertions.assertThat(result).contains(expectedScriptTagFormat(expected));
}

@Test
Expand All @@ -27,7 +26,7 @@ public void formatsTwoScriptsNicely() {

String result = subject.format(new HashSet<String>(asList(first, second)));

assertThat(result, containsString(expectedScriptTagFormat(first) + "\n" + expectedScriptTagFormat(second)));
Assertions.assertThat(result).contains(expectedScriptTagFormat(first) + "\n" + expectedScriptTagFormat(second));
}

private String expectedScriptTagFormat(String scriptName) {
Expand Down

0 comments on commit 6d2a93c

Please sign in to comment.