rutter 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "json"
4
- require "spec_helper"
5
-
6
- class TestController
7
- def self.call(env)
8
- hash = env["rutter.params"]
9
- hash["action"] = env["rutter.action"]
10
- [100, {}, [JSON.generate(hash)]]
11
- end
12
- end
13
-
14
- RSpec.describe "ramverk.router_params" do
15
- let(:router) { Rutter.new(controller_suffix: "Controller") }
16
-
17
- def app
18
- router.freeze
19
- end
20
-
21
- it "calls the endpoint (controller)" do
22
- router.get "/books/:title", to: "Test#index"
23
- get "/books/eloquent-ruby"
24
- expect(last_response.status).to eq(100)
25
- expect(last_response.body)
26
- .to eq('{"title":"eloquent-ruby","action":"index"}')
27
- end
28
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- RSpec.describe "Rutter::Builder#redirect" do
6
- let(:router) do
7
- Rutter.new do
8
- get "/legacy-path", to: redirect("/new_path")
9
- get "/legacy-path-custom-status", to: redirect("/new_path", status: 301)
10
- get "/new_path", to: ->(_env) { [200, {}, ["Redirected"]] }
11
- end
12
- end
13
-
14
- def app
15
- router.freeze
16
- end
17
-
18
- it "redirect the request to the new path" do
19
- get "/legacy-path"
20
-
21
- expect(last_response.status).to eq(302)
22
- expect(last_response.body).to eq("")
23
-
24
- follow_redirect!
25
-
26
- expect(last_response.status).to eq(200)
27
- expect(last_response.body).to eq("Redirected")
28
- end
29
-
30
- it "support setting custom status" do
31
- get "/legacy-path-custom-status"
32
- expect(last_response.status).to eq(301)
33
- follow_redirect!
34
- expect(last_response.status).to eq(200)
35
- end
36
- end