Skip to content

Commit c2d379b

Browse files
committed
F!! Cleaned up how we use Namers
1 parent c05447c commit c2d379b

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

approvaltests-tests/src/test/java/org/approvaltests/namer/NamerFactoryForOptionsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void oldExampleForDocs()
2727
// begin-snippet: namer_factory_example
2828
try (NamedEnvironment namer = NamerFactory.withParameters("title", "chapter"))
2929
{
30-
Approvals.verify("data");
30+
Approvals.verify("data", Approvals.NAMES.withParameters("title", "chapter"));
3131
}
3232
// end-snippet
3333
}

approvaltests-tests/src/test/java/org/approvaltests/namer/NamerFactoryTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ public void testMultipleFiles()
1717
Approvals.verify("two");
1818
}
1919
}
20+
@Test
21+
public void testMultipleFilesViaOptions()
22+
{
23+
NamerFactoryForOptions.FileCounter labeller = Approvals.NAMES.useMultipleFiles();
24+
Approvals.verify("one", labeller.next());
25+
Approvals.verify("two", labeller.next());
26+
}
2027
@ParameterizedTest
2128
@CsvSource({"Oskar,4", "Birgit,1"})
2229
void testNamingWithMultipleParameters(String name, int age)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
one
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
two

approvaltests/src/main/java/org/approvaltests/namer/NamerFactoryForOptions.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,15 @@ public Options withParameters(Options options, String... parameters)
3737
}
3838
return options;
3939
}
40+
41+
public FileCounter useMultipleFiles() {
42+
return new FileCounter();
43+
}
44+
45+
public static class FileCounter {
46+
int counter;
47+
public Options next() {
48+
return new Options().forFile().withAdditionalInformation("" + ++counter);
49+
}
50+
}
4051
}

0 commit comments

Comments
 (0)