rails-rfc6570 2.4.0 → 2.5.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.
@@ -3,110 +3,130 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe ::Rails::RFC6570::Visitor do
6
+ subject(:accept) { visitor.accept(node) }
7
+
6
8
  let(:visitor) { described_class.new }
7
9
  let(:node) { ::ActionDispatch::Journey::Parser.new.parse(path) }
8
10
 
9
- subject { visitor.accept(node) }
10
-
11
11
  describe '/' do
12
12
  let(:path) { '/' }
13
+
13
14
  it { is_expected.to eq %w[/] }
14
15
  end
15
16
 
16
17
  describe '/path/path' do
17
18
  let(:path) { '/path/path' }
19
+
18
20
  it { is_expected.to eq %w[/ path / path] }
19
21
  end
20
22
 
21
23
  describe '/:title' do
22
24
  let(:path) { '/:title' }
25
+
23
26
  it { is_expected.to eq %w[/ {title}] }
24
27
  end
25
28
 
26
29
  describe '/:title(.:format)' do
27
30
  let(:path) { '/:title(.:format)' }
31
+
28
32
  it { is_expected.to eq %w[/ {title} {.format}] }
29
33
  end
30
34
 
31
35
  describe '/path/:title' do
32
36
  let(:path) { '/path/:title' }
37
+
33
38
  it { is_expected.to eq %w[/ path / {title}] }
34
39
  end
35
40
 
36
41
  describe '/path/pre-(:id)-post' do
37
42
  let(:path) { '/path/pre-(:id)-post' }
43
+
38
44
  it { is_expected.to eq %w[/ path / pre- {id} -post] }
39
45
  end
40
46
 
41
47
  describe '/path(/:title)' do
42
48
  let(:path) { '/path(/:title)' }
49
+
43
50
  it { is_expected.to eq %w[/ path {/title}] }
44
51
  end
45
52
 
46
53
  describe '/path/*capture/:title' do
47
54
  let(:path) { '/path/*capture/:title' }
55
+
48
56
  it { is_expected.to eq %w[/ path {/capture*} / {title}] }
49
57
  end
50
58
 
51
59
  describe '/path(/*capture)/:title' do
52
60
  let(:path) { '/path(/*capture)/:title' }
61
+
53
62
  it { is_expected.to eq %w[/ path {/capture*} / {title}] }
54
63
  end
55
64
 
56
65
  describe '/path(/*capture)(/:title)' do
57
66
  let(:path) { '/path(/*capture)(/:title)' }
67
+
58
68
  it { is_expected.to eq %w[/ path {/capture*} {/title}] }
59
69
  end
60
70
 
61
71
  describe '*a/path/*b' do
62
72
  let(:path) { '*a/path/*b' }
73
+
63
74
  it { is_expected.to eq %w[{/a*} / path {/b*}] }
64
75
  end
65
76
 
66
77
  describe 'path/*a/path/*b' do
67
78
  let(:path) { 'path/*a/path/*b' }
79
+
68
80
  it { is_expected.to eq %w[path {/a*} / path {/b*}] }
69
81
  end
70
82
 
71
83
  describe 'path/*a/*b' do
72
84
  let(:path) { 'path/*a/*b' }
85
+
73
86
  it { is_expected.to eq %w[path {/a*} {/b*}] }
74
87
  end
75
88
 
76
89
  describe 'path/*a/:title' do
77
90
  let(:path) { 'path/*a/:title' }
91
+
78
92
  it { is_expected.to eq %w[path {/a*} / {title}] }
79
93
  end
80
94
 
81
95
  describe 'path/*a(/:title)' do
82
96
  let(:path) { 'path/*a(/:title)' }
97
+
83
98
  it { is_expected.to eq %w[path {/a*} {/title}] }
84
99
  end
85
100
 
86
101
  describe '/(:title)' do
87
102
  let(:path) { '/(:title)' }
103
+
88
104
  it { is_expected.to eq %w[/ {title}] }
89
105
  end
90
106
 
91
107
  describe '(/:title)' do
92
108
  let(:path) { '(/:title)' }
109
+
93
110
  it { is_expected.to eq %w[{/title}] }
94
111
  end
95
112
 
96
113
  describe '(/:title/)' do
97
114
  let(:path) { '(/:title/)' }
115
+
98
116
  it { is_expected.to eq %w[{/title} /] }
99
117
  end
100
118
 
101
119
  describe '(/:a(/:b))' do
102
120
  let(:path) { '(/:a(/:b))' }
121
+
103
122
  it { is_expected.to eq %w[{/a} {/b}] }
104
123
  end
105
124
 
106
125
  describe '(/a)|(/b)' do
107
126
  let(:path) { '(/a)|(/b)' }
127
+
108
128
  it do
109
- expect { subject }.to \
129
+ expect { accept }.to \
110
130
  raise_error 'OR nodes cannot be serialized to URI templates'
111
131
  end
112
132
  end
@@ -9,7 +9,8 @@ end
9
9
  Dummy::Application.routes.draw do
10
10
  get '/' => 'api#index', as: :root
11
11
 
12
- get '/path/to/unnamed' => 'api#index', as: nil # Unnamed routes should be ignored
12
+ # Unnamed routes should be ignored
13
+ get '/path/to/unnamed' => 'api#index', as: nil
13
14
 
14
15
  get '/action' => 'api#action', as: :action
15
16
 
@@ -55,35 +56,36 @@ describe Rails::RFC6570, type: :request do
55
56
  context 'root' do
56
57
  before { get '/' }
57
58
 
58
- it 'should return list of all parsed and named routes' do
59
- expect(json.keys).to match_array %w[root action test1 test2 test3 test4 test5 test6]
59
+ it 'returns list of all parsed and named routes' do
60
+ expect(json.keys).to match_array \
61
+ %w[root action test1 test2 test3 test4 test5 test6]
60
62
  end
61
63
 
62
- it 'should include known parameters' do
64
+ it 'includes known parameters' do
63
65
  expect(json['action']).to eq "#{host}/action{?param1,param2}"
64
66
  end
65
67
 
66
- it 'should parse capture symbols' do
68
+ it 'parses capture symbols' do
67
69
  expect(json['test1']).to eq "#{host}/path/{title}"
68
70
  end
69
71
 
70
- it 'should parse capture group' do
72
+ it 'parses capture group' do
71
73
  expect(json['test2']).to eq "#{host}/path/pp-{title}-abc"
72
74
  end
73
75
 
74
- it 'should parse capture group with slash included' do
76
+ it 'parses capture group with slash included' do
75
77
  expect(json['test3']).to eq "#{host}/path{/title}"
76
78
  end
77
79
 
78
- it 'should parse splash operator (I)' do
80
+ it 'parses splash operator (I)' do
79
81
  expect(json['test4']).to eq "#{host}/path{/capture*}/{title}"
80
82
  end
81
83
 
82
- it 'should parse splash operator (II)' do
84
+ it 'parses splash operator (II)' do
83
85
  expect(json['test5']).to eq "#{host}/path{/capture*}/{title}"
84
86
  end
85
87
 
86
- it 'should parse splash operator (III)' do
88
+ it 'parses splash operator (III)' do
87
89
  expect(json['test6']).to eq "#{host}/path{/capture*}{/title}"
88
90
  end
89
91
  end
@@ -91,46 +93,44 @@ describe Rails::RFC6570, type: :request do
91
93
  context 'action' do
92
94
  before { get '/action', headers: headers }
93
95
 
94
- it 'should include URL helpers' do
96
+ it 'includes URL helpers' do
95
97
  expect(response.status).to eq 200
96
98
  end
97
99
 
98
- it 'should allow to return and render templates' do
100
+ it 'allows to return and render templates' do
99
101
  expect(json['template']).to eq "#{host}/action{?param1,param2}"
100
102
  end
101
103
 
102
- it 'should allow to return and render url templates' do
104
+ it 'allows to return and render url templates' do
103
105
  expect(json['template_url']).to eq "#{host}/action{?param1,param2}"
104
106
  end
105
107
 
106
- it 'should allow to return and render path templates' do
108
+ it 'allows to return and render path templates' do
107
109
  expect(json['template_path']).to eq '/action{?param1,param2}'
108
110
  end
109
111
 
110
- it 'should allow to return and render partial expanded templates' do
112
+ it 'allows to return and render partial expanded templates' do
111
113
  expect(json['partial']).to eq "#{host}/path{/capture*}/TITLE"
112
114
  end
113
115
 
114
- it 'should allow to return and render expanded templates' do
116
+ it 'allows to return and render expanded templates (I)' do
115
117
  expect(json['ignore']).to eq "#{host}/path{/capture*}{.format}"
116
118
  end
117
119
 
118
- it 'should allow to return and render expanded templates' do
120
+ it 'allows to return and render expanded templates (II)' do
119
121
  expect(json['expand']).to eq "#{host}/path/a/b/TITLE"
120
122
  end
121
123
 
122
- if Rails::VERSION::MAJOR >= 5
123
- context 'with origin_script_name' do
124
- let(:headers) { {'__OSN' => '/fuubar'} }
124
+ context 'with origin_script_name' do
125
+ let(:headers) { {'__OSN' => '/fuubar'} }
125
126
 
126
- before do
127
- # Consistency check with normal URL helper
128
- expect(json['ref']).to eq "#{host}/fuubar/action"
129
- end
127
+ before do
128
+ # Consistency check with normal URL helper
129
+ expect(json['ref']).to eq "#{host}/fuubar/action"
130
+ end
130
131
 
131
- it 'prefixes origin script name' do
132
- expect(json['template']).to eq "#{host}/fuubar/action{?param1,param2}"
133
- end
132
+ it 'prefixes origin script name' do
133
+ expect(json['template']).to eq "#{host}/fuubar/action{?param1,param2}"
134
134
  end
135
135
  end
136
136
  end
@@ -1,9 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Coverage
4
- require 'coveralls'
5
- Coveralls.wear! do
6
- add_filter 'spec'
4
+ require 'simplecov'
5
+ SimpleCov.start
6
+
7
+ if ENV['CI']
8
+ require 'codecov'
9
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
7
10
  end
8
11
 
9
12
  ENV['RAILS_ENV'] ||= 'test'
@@ -14,7 +17,7 @@ Rails.backtrace_cleaner.remove_silencers!
14
17
 
15
18
  # Requires supporting ruby files with custom matchers and macros, etc,
16
19
  # in spec/support/ and its subdirectories.
17
- Dir[File.expand_path('support/**/*.rb', __dir__)].each {|f| require f }
20
+ Dir[File.expand_path('support/**/*.rb', __dir__)].sort.each {|f| require f }
18
21
 
19
22
  # Checks for pending migrations before tests are run.
20
23
  # If you are not using ActiveRecord, you can remove this line.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-rfc6570
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-23 00:00:00.000000000 Z
11
+ date: 2020-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '4.2'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6.1'
22
+ version: '6.2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '4.2'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6.1'
32
+ version: '6.2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: addressable
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -104,7 +104,7 @@ files:
104
104
  - spec/dummy/public/500.html
105
105
  - spec/dummy/public/favicon.ico
106
106
  - spec/rails/rfc6570/visitor_spec.rb
107
- - spec/rfc6570_spec.rb
107
+ - spec/rails/rfc6570_spec.rb
108
108
  - spec/spec_helper.rb
109
109
  homepage: https://github.com/jgraichen/rails-rfc6570
110
110
  licenses:
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 3.0.6
128
+ rubygems_version: 3.1.2
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Pragmatical access to your Rails routes as RFC6570 URI templates.
@@ -160,5 +160,5 @@ test_files:
160
160
  - spec/dummy/public/500.html
161
161
  - spec/dummy/public/favicon.ico
162
162
  - spec/rails/rfc6570/visitor_spec.rb
163
- - spec/rfc6570_spec.rb
163
+ - spec/rails/rfc6570_spec.rb
164
164
  - spec/spec_helper.rb