|
12 | 12 | specify 'The original route path is not mutated' do
|
13 | 13 | route = Struct.new(:version, :path).new
|
14 | 14 | route.path = '/foo/:dynamic/bar'
|
15 |
| - subject.build(route, add_version: true) |
| 15 | + subject.build(route, route.path.dup, add_version: true) |
16 | 16 | expect(route.path).to eq '/foo/:dynamic/bar'
|
17 | 17 | end
|
18 | 18 |
|
|
23 | 23 |
|
24 | 24 | specify 'The returned path includes version' do
|
25 | 25 | route.path = '/{version}/thing(.json)'
|
26 |
| - expect(subject.build(route, options)).to eql ['Thing', '/v1/thing'] |
| 26 | + expect(subject.build(route, route.path.dup, options)).to eql ['Thing', '/v1/thing'] |
27 | 27 | route.path = '/{version}/thing/foo(.json)'
|
28 |
| - expect(subject.build(route, options)).to eql ['Foo', '/v1/thing/foo'] |
| 28 | + expect(subject.build(route, route.path.dup, options)).to eql ['Foo', '/v1/thing/foo'] |
29 | 29 | route.path = '/{version}/thing(.:format)'
|
30 |
| - expect(subject.build(route, options)).to eql ['Thing', '/v1/thing'] |
| 30 | + expect(subject.build(route, route.path.dup, options)).to eql ['Thing', '/v1/thing'] |
31 | 31 | route.path = '/{version}/thing/foo(.:format)'
|
32 |
| - expect(subject.build(route, options)).to eql ['Foo', '/v1/thing/foo'] |
| 32 | + expect(subject.build(route, route.path.dup, options)).to eql ['Foo', '/v1/thing/foo'] |
33 | 33 | route.path = '/{version}/thing/:id'
|
34 |
| - expect(subject.build(route, options)).to eql ['Thing', '/v1/thing/{id}'] |
| 34 | + expect(subject.build(route, route.path.dup, options)).to eql ['Thing', '/v1/thing/{id}'] |
35 | 35 | route.path = '/{version}/thing/foo/:id'
|
36 |
| - expect(subject.build(route, options)).to eql ['Foo', '/v1/thing/foo/{id}'] |
| 36 | + expect(subject.build(route, route.path.dup, options)).to eql ['Foo', '/v1/thing/foo/{id}'] |
37 | 37 | end
|
38 | 38 | end
|
39 | 39 |
|
|
43 | 43 |
|
44 | 44 | specify 'The returned path does not include version' do
|
45 | 45 | route.path = '/{version}/thing(.json)'
|
46 |
| - expect(subject.build(route, options)).to eql ['Thing', '/thing'] |
| 46 | + expect(subject.build(route, route.path.dup, options)).to eql ['Thing', '/thing'] |
47 | 47 | route.path = '/{version}/thing/foo(.json)'
|
48 |
| - expect(subject.build(route, options)).to eql ['Foo', '/thing/foo'] |
| 48 | + expect(subject.build(route, route.path.dup, options)).to eql ['Foo', '/thing/foo'] |
49 | 49 | route.path = '/{version}/thing(.:format)'
|
50 |
| - expect(subject.build(route, options)).to eql ['Thing', '/thing'] |
| 50 | + expect(subject.build(route, route.path.dup, options)).to eql ['Thing', '/thing'] |
51 | 51 | route.path = '/{version}/thing/foo(.:format)'
|
52 |
| - expect(subject.build(route, options)).to eql ['Foo', '/thing/foo'] |
| 52 | + expect(subject.build(route, route.path.dup, options)).to eql ['Foo', '/thing/foo'] |
53 | 53 | route.path = '/{version}/thing/:id'
|
54 |
| - expect(subject.build(route, options)).to eql ['Thing', '/thing/{id}'] |
| 54 | + expect(subject.build(route, route.path.dup, options)).to eql ['Thing', '/thing/{id}'] |
55 | 55 | route.path = '/{version}/thing/foo/:id'
|
56 |
| - expect(subject.build(route, options)).to eql ['Foo', '/thing/foo/{id}'] |
| 56 | + expect(subject.build(route, route.path.dup, options)).to eql ['Foo', '/thing/foo/{id}'] |
57 | 57 | end
|
58 | 58 | end
|
59 | 59 |
|
|
63 | 63 |
|
64 | 64 | specify 'The returned path does not include version' do
|
65 | 65 | route.path = '/{version}/thing(.json)'
|
66 |
| - expect(subject.build(route, options)).to eql ['Thing', '/thing'] |
| 66 | + expect(subject.build(route, route.path.dup, options)).to eql ['Thing', '/thing'] |
67 | 67 | route.path = '/{version}/thing/foo(.json)'
|
68 |
| - expect(subject.build(route, options)).to eql ['Foo', '/thing/foo'] |
| 68 | + expect(subject.build(route, route.path.dup, options)).to eql ['Foo', '/thing/foo'] |
69 | 69 | route.path = '/{version}/thing(.:format)'
|
70 |
| - expect(subject.build(route, options)).to eql ['Thing', '/thing'] |
| 70 | + expect(subject.build(route, route.path.dup, options)).to eql ['Thing', '/thing'] |
71 | 71 | route.path = '/{version}/thing/foo(.:format)'
|
72 |
| - expect(subject.build(route, options)).to eql ['Foo', '/thing/foo'] |
| 72 | + expect(subject.build(route, route.path.dup, options)).to eql ['Foo', '/thing/foo'] |
73 | 73 | route.path = '/{version}/thing/:id'
|
74 |
| - expect(subject.build(route, options)).to eql ['Thing', '/thing/{id}'] |
| 74 | + expect(subject.build(route, route.path.dup, options)).to eql ['Thing', '/thing/{id}'] |
75 | 75 | route.path = '/{version}/thing/foo/:id'
|
76 |
| - expect(subject.build(route, options)).to eql ['Foo', '/thing/foo/{id}'] |
| 76 | + expect(subject.build(route, route.path.dup, options)).to eql ['Foo', '/thing/foo/{id}'] |
77 | 77 | end
|
78 | 78 | end
|
79 | 79 |
|
|
83 | 83 |
|
84 | 84 | specify 'The returned path does not include version' do
|
85 | 85 | route.path = '/{version}/thing(.json)'
|
86 |
| - expect(subject.build(route, options)).to eql ['Thing', '/thing'] |
| 86 | + expect(subject.build(route, route.path.dup, options)).to eql ['Thing', '/thing'] |
87 | 87 | route.path = '/{version}/thing/foo(.json)'
|
88 |
| - expect(subject.build(route, options)).to eql ['Foo', '/thing/foo'] |
| 88 | + expect(subject.build(route, route.path.dup, options)).to eql ['Foo', '/thing/foo'] |
89 | 89 | route.path = '/{version}/thing(.:format)'
|
90 |
| - expect(subject.build(route, options)).to eql ['Thing', '/thing'] |
| 90 | + expect(subject.build(route, route.path.dup, options)).to eql ['Thing', '/thing'] |
91 | 91 | route.path = '/{version}/thing/foo(.:format)'
|
92 |
| - expect(subject.build(route, options)).to eql ['Foo', '/thing/foo'] |
| 92 | + expect(subject.build(route, route.path.dup, options)).to eql ['Foo', '/thing/foo'] |
93 | 93 | route.path = '/{version}/thing/:id'
|
94 |
| - expect(subject.build(route, options)).to eql ['Thing', '/thing/{id}'] |
| 94 | + expect(subject.build(route, route.path.dup, options)).to eql ['Thing', '/thing/{id}'] |
95 | 95 | route.path = '/{version}/thing/foo/:id'
|
96 |
| - expect(subject.build(route, options)).to eql ['Foo', '/thing/foo/{id}'] |
| 96 | + expect(subject.build(route, route.path.dup, options)).to eql ['Foo', '/thing/foo/{id}'] |
97 | 97 | end
|
98 | 98 | end
|
99 | 99 | end
|
|
0 commit comments