@@ -17,7 +17,7 @@ def output
17
17
end
18
18
19
19
context "generating for app" do
20
- it "generates an operation" do
20
+ it "generates an operation without a namespace, with a recommendation " do
21
21
subject . call ( name : "add_book" )
22
22
23
23
operation_file = <<~EXPECTED
@@ -33,6 +33,7 @@ def call
33
33
34
34
expect ( fs . read ( "app/add_book.rb" ) ) . to eq ( operation_file )
35
35
expect ( output ) . to include ( "Created app/add_book.rb" )
36
+ expect ( output ) . to include ( " Recommendation: Add a namespace to operation names, so they go into a folder within app/" )
36
37
end
37
38
38
39
it "generates a operation in a deep namespace with default separator" do
@@ -81,7 +82,7 @@ def call
81
82
end
82
83
83
84
context "generating for a slice" do
84
- it "generates a operation in a top-level namespace" do
85
+ it "generates a operation in a top-level namespace, with recommendation " do
85
86
fs . mkdir ( "slices/main" )
86
87
subject . call ( name : "add_book" , slice : "main" )
87
88
@@ -98,6 +99,30 @@ def call
98
99
99
100
expect ( fs . read ( "slices/main/add_book.rb" ) ) . to eq ( operation_file )
100
101
expect ( output ) . to include ( "Created slices/main/add_book.rb" )
102
+ expect ( output ) . to include ( " Recommendation: Add a namespace to operation names, so they go into a folder within slices/main/" )
103
+ end
104
+
105
+ it "generates a operation in a nested namespace" do
106
+ fs . mkdir ( "slices/main" )
107
+ subject . call ( name : "admin.books.add" , slice : "main" )
108
+
109
+ operation_file = <<~EXPECTED
110
+ # frozen_string_literal: true
111
+
112
+ module Main
113
+ module Admin
114
+ module Books
115
+ class Add < Main::Operation
116
+ def call
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
122
+ EXPECTED
123
+
124
+ expect ( fs . read ( "slices/main/admin/books/add.rb" ) ) . to eq ( operation_file )
125
+ expect ( output ) . to include ( "Created slices/main/admin/books/add.rb" )
101
126
end
102
127
end
103
128
end
0 commit comments