File tree Expand file tree Collapse file tree 2 files changed +66
-0
lines changed
marten/cli/manage/command Expand file tree Collapse file tree 2 files changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ require " ./spec_helper"
2
+
3
+ describe Marten ::CLI ::Manage ::Command ::Routes do
4
+ describe " #run" do
5
+ it " displays top-level routes as expected" do
6
+ stdout = IO ::Memory .new
7
+ stderr = IO ::Memory .new
8
+
9
+ command = Marten ::CLI ::Manage ::Command ::Routes .new(
10
+ options: [] of String ,
11
+ stdout: stdout,
12
+ stderr: stderr
13
+ )
14
+
15
+ command.run
16
+
17
+ output = stdout.rewind.gets_to_end
18
+ output.includes?(" /dummy/<id:int>/and/<scope:slug>" ).should be_true
19
+ output.includes?(" [dummy_with_id_and_scope]" ).should be_true
20
+ end
21
+
22
+ it " displays nested routes involving a single namespace as expected" do
23
+ stdout = IO ::Memory .new
24
+ stderr = IO ::Memory .new
25
+
26
+ command = Marten ::CLI ::Manage ::Command ::Routes .new(
27
+ options: [] of String ,
28
+ stdout: stdout,
29
+ stderr: stderr
30
+ )
31
+
32
+ command.run
33
+
34
+ output = stdout.rewind.gets_to_end
35
+ output.includes?(" /nested-1/dummy/<id:int>" ).should be_true
36
+ output.includes?(" [nested_1:dummy_with_id]" ).should be_true
37
+ end
38
+
39
+ it " displays nested routes involving multiple namespaces as expected" do
40
+ stdout = IO ::Memory .new
41
+ stderr = IO ::Memory .new
42
+
43
+ command = Marten ::CLI ::Manage ::Command ::Routes .new(
44
+ options: [] of String ,
45
+ stdout: stdout,
46
+ stderr: stderr
47
+ )
48
+
49
+ command.run
50
+
51
+ output = stdout.rewind.gets_to_end
52
+ output.includes?(" /nested-1/nested-2/dummy/<id:int>" ).should be_true
53
+ output.includes?(" [nested_1:nested_2:dummy_with_id]" ).should be_true
54
+ end
55
+ end
56
+ end
Original file line number Diff line number Diff line change @@ -97,6 +97,15 @@ Marten.configure :test do |config|
97
97
config.media_files.root = " spec/media"
98
98
end
99
99
100
+ NESTED_ROUTES_2 = Marten ::Routing ::Map .draw do
101
+ path " /dummy/<id:int>" , DummyHandler , name: " dummy_with_id"
102
+ end
103
+
104
+ NESTED_ROUTES_1 = Marten ::Routing ::Map .draw do
105
+ path " /dummy/<id:int>" , DummyHandler , name: " dummy_with_id"
106
+ path " /nested-2" , NESTED_ROUTES_2 , name: " nested_2"
107
+ end
108
+
100
109
Marten .routes.draw do
101
110
path " /dummy" , DummyHandler , name: " dummy"
102
111
path " /dummy/<id:int>" , DummyHandler , name: " dummy_with_id"
@@ -111,4 +120,5 @@ Marten.routes.draw do
111
120
path " /cookie-value-set" , CookieValueSetHandler , name: " cookie_value_set"
112
121
path " /simple-schema" , SimpleSchemaHandler , name: " simple_schema"
113
122
path " /simple-file-schema" , SimpleFileSchemaHandler , name: " simple_file_schema"
123
+ path " /nested-1" , NESTED_ROUTES_1 , name: " nested_1"
114
124
end
You can’t perform that action at this time.
0 commit comments