|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -describe Grape::Path do |
4 | | - describe '#origin' do |
5 | | - context 'mount_path' do |
6 | | - it 'is not included when it is nil' do |
7 | | - path = described_class.new(nil, nil, mount_path: '/foo/bar') |
8 | | - expect(path.origin).to eql '/foo/bar' |
9 | | - end |
10 | | - |
11 | | - it 'is included when it is not nil' do |
12 | | - path = described_class.new(nil, nil, {}) |
13 | | - expect(path.origin).to eql('/') |
14 | | - end |
15 | | - end |
16 | | - |
17 | | - context 'root_prefix' do |
18 | | - it 'is not included when it is nil' do |
19 | | - path = described_class.new(nil, nil, {}) |
20 | | - expect(path.origin).to eql('/') |
21 | | - end |
22 | | - |
23 | | - it 'is included after the mount path' do |
24 | | - path = described_class.new( |
25 | | - nil, |
26 | | - nil, |
27 | | - mount_path: '/foo', |
28 | | - root_prefix: '/hello' |
29 | | - ) |
30 | | - |
31 | | - expect(path.origin).to eql('/foo/hello') |
32 | | - end |
33 | | - end |
34 | | - |
35 | | - it 'uses the namespace after the mount path and root prefix' do |
36 | | - path = described_class.new( |
37 | | - nil, |
38 | | - 'namespace', |
39 | | - mount_path: '/foo', |
40 | | - root_prefix: '/hello' |
41 | | - ) |
42 | | - |
43 | | - expect(path.origin).to eql('/foo/hello/namespace') |
44 | | - end |
45 | | - |
46 | | - it 'uses the raw path after the namespace' do |
47 | | - path = described_class.new( |
48 | | - 'raw_path', |
49 | | - 'namespace', |
50 | | - mount_path: '/foo', |
51 | | - root_prefix: '/hello' |
52 | | - ) |
53 | | - |
54 | | - expect(path.origin).to eql('/foo/hello/namespace/raw_path') |
55 | | - end |
56 | | - end |
57 | | - |
58 | | - describe '#suffix' do |
59 | | - context 'when using a specific format' do |
60 | | - it 'accepts specified format' do |
61 | | - path = described_class.new(nil, nil, format: 'json', content_types: 'application/json') |
62 | | - expect(path.suffix).to eql('(.json)') |
63 | | - end |
64 | | - end |
65 | | - |
66 | | - context 'when path versioning is used' do |
67 | | - it "includes a '/'" do |
68 | | - path = described_class.new(nil, nil, version: :v1, version_options: Grape::DSL::VersionOptions.new) |
69 | | - expect(path.suffix).to eql('(/.:format)') |
70 | | - end |
71 | | - end |
72 | | - |
73 | | - context 'when path versioning is not used' do |
74 | | - it "does not include a '/' when the path has a namespace" do |
75 | | - path = described_class.new(nil, 'namespace', {}) |
76 | | - expect(path.suffix).to eql('(.:format)') |
77 | | - end |
78 | | - |
79 | | - it "does not include a '/' when the path has a path" do |
80 | | - path = described_class.new('/path', nil, version: :v1, version_options: Grape::DSL::VersionOptions.new) |
81 | | - expect(path.suffix).to eql('(.:format)') |
82 | | - end |
83 | | - |
84 | | - it "includes a '/' otherwise" do |
85 | | - path = described_class.new(nil, nil, version: :v1, version_options: Grape::DSL::VersionOptions.new) |
86 | | - expect(path.suffix).to eql('(/.:format)') |
87 | | - end |
88 | | - end |
| 3 | +RSpec.describe 'Grape::Path' do |
| 4 | + it 'is deprecated and points at Grape::Router::Pattern::Path' do |
| 5 | + expect { Grape::Path.new(nil, nil, {}) }.to raise_error( |
| 6 | + ActiveSupport::DeprecationException, /Grape::Path is deprecated.*Grape::Router::Pattern::Path/m |
| 7 | + ) |
89 | 8 | end |
90 | 9 | end |
0 commit comments