sinatra-bouncer 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -7
- data/.rubocop.yml +1 -9
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -3
- data/Gemfile.lock +92 -0
- data/README.md +212 -52
- data/RELEASE_NOTES.md +153 -0
- data/lib/sinatra/bouncer/basic_bouncer.rb +36 -18
- data/lib/sinatra/bouncer/rule.rb +12 -4
- data/lib/sinatra/bouncer/version.rb +1 -1
- data/lib/sinatra/bouncer.rb +7 -27
- data/sinatra_bouncer.gemspec +4 -1
- metadata +5 -14
- data/tests/integrations/dev_defines_legal_routes.feature +0 -57
- data/tests/integrations/dev_installs_bouncer.feature +0 -12
- data/tests/integrations/step_definitions/given.rb +0 -36
- data/tests/integrations/step_definitions/then.rb +0 -9
- data/tests/integrations/step_definitions/when.rb +0 -11
- data/tests/integrations/support/env.rb +0 -30
- data/tests/integrations/support/helpers.rb +0 -55
- data/tests/integrations/support/types.rb +0 -21
- data/tests/spec/basic_bouncer_spec.rb +0 -148
- data/tests/spec/rule_spec.rb +0 -67
- data/tests/spec/spec_helper.rb +0 -11
- data/tests/test_app.rb +0 -9
data/tests/spec/rule_spec.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'spec_helper'
|
4
|
-
|
5
|
-
describe Sinatra::Bouncer::Rule do
|
6
|
-
describe '#match_path?' do
|
7
|
-
it 'should match simple paths' do
|
8
|
-
rule = Sinatra::Bouncer::Rule.new('/some_path') { true }
|
9
|
-
|
10
|
-
expect(rule.match_path?('/some_path')).to be true
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should append leading slashes to the given path' do
|
14
|
-
rule = Sinatra::Bouncer::Rule.new('some_path') { true }
|
15
|
-
|
16
|
-
expect(rule.match_path?('/some_path')).to be true
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should append leading slashes to the tested path' do
|
20
|
-
rule = Sinatra::Bouncer::Rule.new('/other_path') { true }
|
21
|
-
|
22
|
-
expect(rule.match_path?('other_path')).to be true
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should match splats' do
|
26
|
-
rule = Sinatra::Bouncer::Rule.new('/directory/*') { true }
|
27
|
-
|
28
|
-
%w[/directory/one /directory/two /directory/three].each do |path|
|
29
|
-
expect(rule.match_path?(path)).to be true
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should NOT match empty string to a splat' do
|
34
|
-
rule = Sinatra::Bouncer::Rule.new('/directory/*') { true }
|
35
|
-
|
36
|
-
expect(rule.match_path?('/directory/')).to be false
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should require that both paths are same length' do
|
40
|
-
rule = Sinatra::Bouncer::Rule.new('/directory/*') { true }
|
41
|
-
|
42
|
-
%w[/directory /directory/extra/length].each do |path|
|
43
|
-
expect(rule.match_path?(path)).to be false
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '#rule_passes?' do
|
49
|
-
it 'should raise an error if rule returns nonbool' do
|
50
|
-
rule = Sinatra::Bouncer::Rule.new('/something') { nil }
|
51
|
-
|
52
|
-
expect { rule.rule_passes? }.to raise_error Sinatra::Bouncer::BouncerError
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'should return true when the block is true' do
|
56
|
-
rule = Sinatra::Bouncer::Rule.new('/something') { true }
|
57
|
-
|
58
|
-
expect(rule.rule_passes?).to be true
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'should return true when the block is false' do
|
62
|
-
rule = Sinatra::Bouncer::Rule.new('/something') { false }
|
63
|
-
|
64
|
-
expect(rule.rule_passes?).to be false
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
data/tests/spec/spec_helper.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
src_dir = File.expand_path('../..', __dir__)
|
4
|
-
$LOAD_PATH.unshift(src_dir) unless $LOAD_PATH.include?(src_dir)
|
5
|
-
|
6
|
-
require 'simplecov'
|
7
|
-
|
8
|
-
SimpleCov.command_name 'spec'
|
9
|
-
|
10
|
-
require 'lib/sinatra/bouncer'
|
11
|
-
require 'rspec/matchers'
|