sinatra-bouncer 1.3.0 → 2.0.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,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
@@ -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'
data/tests/test_app.rb DELETED
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'sinatra'
4
- require 'lib/sinatra/bouncer'
5
-
6
- # class TestApp < Sinatra::Base
7
- # register Sinatra::Bouncer
8
-
9
- # end