/
DetectsCoffeeTest.java
47 lines (37 loc) · 1.23 KB
/
DetectsCoffeeTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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;
public class DetectsCoffeeTest {
private final DetectsCoffee subject = new DetectsCoffee();
@Test
public void whenAStringEndingInCoffeeThatsCoffee() {
assertThat("/some/path/to/pants.coffee", is(this.coffee()));
}
@Test
public void whenAStringDoesNotEndInCoffeeThatsNotCoffee() {
assertThat("/some/path/to/pants.cafe", is(not(this.coffee())));
}
@Test
public void whenCoffeeHasAQueryStringThatsCoffee() {
assertThat("/some/path/to/pants.coffee?stillCoffee=true", is(this.coffee()));
}
@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) {
}
};
}
}