Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Changing getPath to use path #342

Merged
merged 2 commits into from

2 participants

@mattharr

This is my first go at contributing, so apologies for any mistakes.

As per #337 I've changed FileResource to use getPath rather than getAbsolutePath.

Let me know if I missed anything.

Thanks,

@aslakhellesoy

A general comment: These tests assume Windows. Can you change \\ to Path.separator please?

@aslakhellesoy

Really? I would expect the result to be just test.feature. Did this test pass for you?

@mattharr

Thanks for the comments. You're right the test didn't pass - I thought I'd run it OK, but maybe I fiddled with it after. Anyway, all cleared up now, and hopefully all the windows assumptions fixed.

@aslakhellesoy aslakhellesoy merged commit 065e7e2 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 12, 2012
  1. @mattharr

    Changing getPath to use path

    mattharr authored
Commits on Jun 13, 2012
  1. @mattharr
This page is out of date. Refresh to see the latest.
View
2  core/src/main/java/cucumber/io/FileResource.java
@@ -20,7 +20,7 @@ public FileResource(File root, File file) {
@Override
public String getPath() {
if (file.equals(root)) {
- return file.getAbsolutePath();
+ return file.getPath();
} else {
return file.getAbsolutePath().substring(root.getAbsolutePath().length() + 1);
}
View
27 core/src/test/java/cucumber/io/FileResourceTest.java
@@ -0,0 +1,27 @@
+package cucumber.io;
+
+import java.io.File;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+public class FileResourceTest {
+
+ @Test
+ public void get_path_should_return_short_path_when_root_same_as_file() {
+ // setup
+ FileResource toTest = new FileResource(new File("test1/test.feature"), new File("test1/test.feature"));
+
+ // test
+ assertEquals("test1" + File.separator + "test.feature", toTest.getPath());
+ }
+
+ @Test
+ public void get_path_should_return_truncated_path_when_absolute_file_paths_are_input() {
+ // setup
+ FileResource toTest = new FileResource(new File("/testPath/test1"), new File("/testPath/test1/test.feature"));
+
+ // test
+ assertEquals("test.feature", toTest.getPath());
+ }
+}
Something went wrong with that request. Please try again.