Skip to content

Commit 5c2ca1a

Browse files
authored
chore: add spec for route globbing (#87)
1 parent fd50b1f commit 5c2ca1a

5 files changed

Lines changed: 52 additions & 42 deletions

File tree

shard.yml

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
name: action-controller
2-
version: 7.6.0
3-
crystal: ">= 1.9.0"
4-
5-
dependencies:
6-
habitat:
7-
github: luckyframework/habitat
8-
version: ">= 0.4"
9-
lucky_router:
10-
github: luckyframework/lucky_router
11-
version: ">= 0.5"
12-
exception_page:
13-
github: crystal-loot/exception_page
14-
version: ">= 0.5"
15-
16-
# Required for running specs in client apps
17-
hot_topic:
18-
github: jgaskins/hot_topic
19-
20-
# Used for generating OpenAPI
21-
json-schema:
22-
github: spider-gazelle/json-schema
23-
version: ">= 1.3"
24-
25-
development_dependencies:
26-
ameba:
27-
github: veelenga/ameba
28-
kilt:
29-
github: jeromegn/kilt
30-
31-
authors:
32-
- Stephen von Takach <steve@place.tech>
33-
- Caspian Baska <caspian@place.tech>
34-
- Kim Burgess <kim@place.tech>
35-
- Duke Nguyen <duke@place.tech>
36-
37-
license: MIT
1+
name: action-controller
2+
version: 7.6.1
3+
crystal: ">= 1.9.0"
4+
5+
dependencies:
6+
habitat:
7+
github: luckyframework/habitat
8+
version: ">= 0.4"
9+
lucky_router:
10+
github: luckyframework/lucky_router
11+
version: ">= 0.6.1"
12+
exception_page:
13+
github: crystal-loot/exception_page
14+
version: ">= 0.5"
15+
16+
# Required for running specs in client apps
17+
hot_topic:
18+
github: jgaskins/hot_topic
19+
20+
# Used for generating OpenAPI
21+
json-schema:
22+
github: spider-gazelle/json-schema
23+
version: ">= 1.3"
24+
25+
development_dependencies:
26+
ameba:
27+
github: veelenga/ameba
28+
kilt:
29+
github: jeromegn/kilt
30+
31+
authors:
32+
- Stephen von Takach <steve@place.tech>
33+
- Caspian Baska <caspian@place.tech>
34+
- Kim Burgess <kim@place.tech>
35+
- Duke Nguyen <duke@place.tech>
36+
37+
license: MIT

spec/route_builder_spec.cr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,10 @@ describe AC::Route::Builder do
226226
})
227227
end
228228
end
229+
230+
it "should work with globs" do
231+
result = client.get("/hello/glob/value")
232+
result.status_code.should eq 200
233+
result.body.should eq "var is value"
234+
end
229235
end

spec/spec_helper.cr

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class Filtering < FilterOrdering
110110
def testing_headers(
111111
@[AC::Param::Info(header: "X-Count", description: "number of requests made", example: "34")]
112112
value : Int32,
113-
query_param : Int32
113+
query_param : Int32,
114114
) : String
115115
"#{value}--#{query_param}"
116116
end
@@ -199,15 +199,15 @@ class Filtering < FilterOrdering
199199
@[AC::Route::GET("/param_annotation/:thing/flexible", config: {thing: {strict: false}})]
200200
def test_param_annotation(
201201
@[AC::Param::Converter(class: IsHotDog, config: {strict: true})]
202-
thing : Bool
202+
thing : Bool,
203203
) : Bool
204204
thing
205205
end
206206

207207
@[AC::Route::GET("/is_this_bool/")]
208208
def test_param_name_error(
209209
@[AC::Param::Info(name: "thing", description: "param name doesn't match variable name", example: "true")]
210-
is_a_bool : Bool
210+
is_a_bool : Bool,
211211
) : Bool?
212212
is_a_bool
213213
end
@@ -404,6 +404,10 @@ class HelloWorld < Application
404404
render text: "var is #{@me}"
405405
end
406406

407+
get "/glob/*", :globglob do
408+
render text: "var is #{params["glob"]}"
409+
end
410+
407411
patch "/:id", :update do
408412
render :accepted, text: "Thanks!"
409413
end

src/action-controller/base.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ abstract class ActionController::Base
748748
#
749749
# ```
750750
# @[AC::Route::Filter(:around_action, only: [:create, :update])]
751-
# def wrap_in_transaction
751+
# def wrap_in_transaction(&)
752752
# PgORM::Database.transaction do
753753
# yield
754754
# end

src/action-controller/open_api.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ module ActionController::OpenAPI
137137
all_filters,
138138
all_exceptions,
139139
route_filters : Array(String),
140-
route_errors : Array(String)
140+
route_errors : Array(String),
141141
) : Tuple(KlassDoc?, Array(String), Array(String))
142142
if description = klass_descriptions[controller]?
143143
matched_filters = route_filters.compact_map do |filter_name|

0 commit comments

Comments
 (0)