tarquinn 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/lib/tarquinn/builder.rb +5 -0
- data/lib/tarquinn/class_methods.rb +4 -0
- data/lib/tarquinn/condition/action_checker.rb +11 -0
- data/lib/tarquinn/condition/method_caller.rb +13 -0
- data/lib/tarquinn/condition/proc_runner.rb +11 -0
- data/lib/tarquinn/condition.rb +5 -0
- data/lib/tarquinn/config.rb +18 -12
- data/lib/tarquinn/controller.rb +19 -0
- data/lib/tarquinn/engine.rb +9 -5
- data/lib/tarquinn/handler.rb +13 -22
- data/lib/tarquinn/version.rb +1 -1
- data/lib/tarquinn.rb +2 -0
- data/spec/lib/tarquinn/condition/action_checker_spec.rb +53 -0
- data/spec/lib/tarquinn/condition/method_caller_spec.rb +50 -0
- data/spec/lib/tarquinn/condition/proc_runner_spec.rb +22 -0
- data/spec/lib/tarquinn/config_spec.rb +21 -17
- data/spec/lib/tarquinn/controller_spec.rb +39 -0
- data/spec/lib/tarquinn/engine_spec.rb +5 -38
- data/spec/lib/tarquinn/handler_spec.rb +15 -4
- data/spec/lib/tarquinn_spec.rb +1 -1
- data/spec/support/models/tarquinn/{controller.rb → dummy_controller.rb} +14 -1
- data/spec/support/shared_examples/config.rb +28 -0
- metadata +13 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e8629e912a90812be4bfecbe735d47213dcc52a
|
4
|
+
data.tar.gz: e2f2c47d5be94b83b3640da3c2629feefca5b3b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a55c1cc2c11d6a2d4db1ef413616761ec8f795875355375b48908f3bf2a5be58865d0a6a65aa7b528bbf744028e409813a8cde170644d5ba7ead4312f5096c0
|
7
|
+
data.tar.gz: c8e2a0466104acb3392a568bc4c1d32fe91b36755537a299a4a926425720fd9e03e2f3f68961d948a9afd22dd5154bdc0f239a11be55a7e7ff5b2497f18d4226
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/tarquinn/builder.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
class Tarquinn::Builder
|
2
|
+
def add_skip_action(redirection, *actions)
|
3
|
+
config_for(redirection).add_skip_action(*actions)
|
4
|
+
end
|
5
|
+
|
2
6
|
def add_redirection_config(redirection, *methods, block)
|
3
7
|
config_for(redirection).add_redirection_rules(*methods, &block)
|
4
8
|
end
|
@@ -8,6 +12,7 @@ class Tarquinn::Builder
|
|
8
12
|
end
|
9
13
|
|
10
14
|
def build(controller)
|
15
|
+
controller = Tarquinn::Controller.new(controller)
|
11
16
|
Tarquinn::Engine.new(configs, controller)
|
12
17
|
end
|
13
18
|
|
@@ -1,4 +1,8 @@
|
|
1
1
|
module Tarquinn::ClassMethods
|
2
|
+
def skip_redirection(redirection, *actions)
|
3
|
+
redirector_builder.add_skip_action(redirection, *actions)
|
4
|
+
end
|
5
|
+
|
2
6
|
def redirection_rule(redirection, *methods, &block)
|
3
7
|
redirector_builder.add_redirection_config(redirection, *methods, block)
|
4
8
|
end
|
data/lib/tarquinn/config.rb
CHANGED
@@ -5,29 +5,35 @@ class Tarquinn::Config
|
|
5
5
|
@redirect = redirect
|
6
6
|
end
|
7
7
|
|
8
|
+
def add_skip_action(*routes)
|
9
|
+
skip_blocks << block_routes(routes)
|
10
|
+
end
|
11
|
+
|
8
12
|
def add_redirection_rules(*methods, &block)
|
9
|
-
|
10
|
-
|
13
|
+
redirection_blocks << block_methods(methods)
|
14
|
+
redirection_blocks << Tarquinn::Condition::ProcRunner.new(&block) if block_given?
|
11
15
|
end
|
12
16
|
|
13
17
|
def add_skip_rules(*methods, &block)
|
14
|
-
|
15
|
-
skip_blocks << block if block_given?
|
18
|
+
skip_blocks << block_methods(methods)
|
19
|
+
skip_blocks << Tarquinn::Condition::ProcRunner.new(&block) if block_given?
|
16
20
|
end
|
17
21
|
|
18
|
-
def
|
19
|
-
@
|
22
|
+
def redirection_blocks
|
23
|
+
@blocks ||= []
|
20
24
|
end
|
21
25
|
|
22
|
-
def
|
23
|
-
@
|
26
|
+
def skip_blocks
|
27
|
+
@skip_blocks ||= []
|
24
28
|
end
|
25
29
|
|
26
|
-
|
27
|
-
|
30
|
+
private
|
31
|
+
|
32
|
+
def block_methods(methods)
|
33
|
+
Tarquinn::Condition::MethodCaller.new(methods)
|
28
34
|
end
|
29
35
|
|
30
|
-
def
|
31
|
-
|
36
|
+
def block_routes(routes)
|
37
|
+
Tarquinn::Condition::ActionChecker.new(routes)
|
32
38
|
end
|
33
39
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Tarquinn::Controller
|
2
|
+
attr_reader :controller
|
3
|
+
|
4
|
+
def initialize(controller)
|
5
|
+
@controller = controller
|
6
|
+
end
|
7
|
+
|
8
|
+
def params
|
9
|
+
@params ||= controller.send(:params)
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(method, *args)
|
13
|
+
controller.send(method, *args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def has_method?(method)
|
17
|
+
controller.respond_to?(method, true)
|
18
|
+
end
|
19
|
+
end
|
data/lib/tarquinn/engine.rb
CHANGED
@@ -6,17 +6,21 @@ class Tarquinn::Engine
|
|
6
6
|
@controller = controller
|
7
7
|
end
|
8
8
|
|
9
|
-
def perform_redirect?
|
10
|
-
handlers.any? { |h| h.perform_redirect? }
|
11
|
-
end
|
12
|
-
|
13
9
|
def perform_redirect
|
14
10
|
return unless perform_redirect?
|
15
|
-
|
11
|
+
handler_redirector.redirect
|
16
12
|
end
|
17
13
|
|
18
14
|
private
|
19
15
|
|
16
|
+
def perform_redirect?
|
17
|
+
handler_redirector.present?
|
18
|
+
end
|
19
|
+
|
20
|
+
def handler_redirector
|
21
|
+
@handler_redirector ||= handlers.find { |h| h.perform_redirect? }
|
22
|
+
end
|
23
|
+
|
20
24
|
def handlers
|
21
25
|
@handlers ||= build_handlers
|
22
26
|
end
|
data/lib/tarquinn/handler.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class Tarquinn::Handler
|
2
2
|
attr_accessor :config, :controller
|
3
3
|
|
4
|
-
delegate :
|
4
|
+
delegate :redirection_blocks, :skip_blocks, to: :config
|
5
5
|
|
6
6
|
def initialize(config, controller)
|
7
7
|
@config = config
|
@@ -9,12 +9,12 @@ class Tarquinn::Handler
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def perform_redirect?
|
12
|
-
@perform_redirect
|
13
|
-
@perform_redirect
|
12
|
+
return @perform_redirect unless @perform_redirect.nil?
|
13
|
+
@perform_redirect = is_redirect?
|
14
14
|
end
|
15
15
|
|
16
16
|
def redirect
|
17
|
-
controller.
|
17
|
+
controller.call(:redirect_to, redirect_path)
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
@@ -24,35 +24,26 @@ class Tarquinn::Handler
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def redirect_path
|
27
|
-
controller.
|
27
|
+
return redirect_method unless controller.has_method?(redirect_method)
|
28
|
+
controller.call redirect_method
|
28
29
|
end
|
29
30
|
|
30
31
|
def is_redirect?
|
31
|
-
return false if
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
def methods_skip_redirect?
|
36
|
-
skip_methods.any? do |method|
|
37
|
-
controller.send(method)
|
38
|
-
end
|
32
|
+
return false if blocks_skip_redirect?
|
33
|
+
blocks_require_redirect?
|
39
34
|
end
|
40
35
|
|
41
36
|
def blocks_skip_redirect?
|
42
|
-
skip_blocks
|
43
|
-
block.yield
|
44
|
-
end
|
37
|
+
check_blocks(skip_blocks)
|
45
38
|
end
|
46
39
|
|
47
|
-
def
|
48
|
-
|
49
|
-
controller.send(method)
|
50
|
-
end
|
40
|
+
def blocks_require_redirect?
|
41
|
+
check_blocks(redirection_blocks)
|
51
42
|
end
|
52
43
|
|
53
|
-
def
|
44
|
+
def check_blocks(blocks)
|
54
45
|
blocks.any? do |block|
|
55
|
-
block.
|
46
|
+
block.check?(controller)
|
56
47
|
end
|
57
48
|
end
|
58
49
|
end
|
data/lib/tarquinn/version.rb
CHANGED
data/lib/tarquinn.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tarquinn::Condition::ActionChecker do
|
4
|
+
let(:dummy_controller) { Tarquinn::DummyController.new }
|
5
|
+
let(:controller) { Tarquinn::Controller.new(dummy_controller) }
|
6
|
+
|
7
|
+
context 'when initialized with a single route' do
|
8
|
+
let(:route) { :show }
|
9
|
+
let(:subject) { described_class.new(route) }
|
10
|
+
|
11
|
+
context 'when receiving a request for the given action' do
|
12
|
+
context 'but it was configured with a symbol' do
|
13
|
+
it do
|
14
|
+
expect(subject.check?(controller)).to be_truthy
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'and it was configured with a string' do
|
19
|
+
let(:route) { 'show' }
|
20
|
+
|
21
|
+
it do
|
22
|
+
expect(subject.check?(controller)).to be_truthy
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when receiving a request for other action action' do
|
28
|
+
let(:route) { :view }
|
29
|
+
|
30
|
+
it do
|
31
|
+
expect(subject.check?(controller)).to be_falsey
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when initialized with more routes' do
|
37
|
+
let(:routes) { [ :show, :view ] }
|
38
|
+
let(:subject) { described_class.new(routes) }
|
39
|
+
|
40
|
+
context 'when receiving a request for one of the given action' do
|
41
|
+
it do
|
42
|
+
expect(subject.check?(controller)).to be_truthy
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when receiving a request for another action' do
|
47
|
+
let(:routes) { [ :update, :view ] }
|
48
|
+
it do
|
49
|
+
expect(subject.check?(controller)).to be_falsey
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tarquinn::Condition::MethodCaller do
|
4
|
+
let(:dummy_controller) { Tarquinn::DummyController.new }
|
5
|
+
let(:controller) { Tarquinn::Controller.new(dummy_controller) }
|
6
|
+
|
7
|
+
context 'when initialized with a single method' do
|
8
|
+
let(:method) { :true }
|
9
|
+
let(:subject) { described_class.new(method) }
|
10
|
+
|
11
|
+
context 'when method returns true' do
|
12
|
+
it do
|
13
|
+
expect(subject.check?(controller)).to be_truthy
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when method returns true' do
|
18
|
+
let(:method) { :false }
|
19
|
+
|
20
|
+
it do
|
21
|
+
expect(subject.check?(controller)).to be_falsey
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when initialized with more methods' do
|
27
|
+
let(:methods) { [ :true, :false ] }
|
28
|
+
let(:subject) { described_class.new(methods) }
|
29
|
+
|
30
|
+
context 'when one return true and the other false' do
|
31
|
+
it do
|
32
|
+
expect(subject.check?(controller)).to be_truthy
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when all return true' do
|
37
|
+
let(:methods) { [ :true, :true ] }
|
38
|
+
it do
|
39
|
+
expect(subject.check?(controller)).to be_truthy
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when all return false' do
|
44
|
+
let(:methods) { [ :false, :false ] }
|
45
|
+
it do
|
46
|
+
expect(subject.check?(controller)).to be_falsey
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tarquinn::Condition::ProcRunner do
|
4
|
+
let(:controller) { double }
|
5
|
+
let(:value) { true }
|
6
|
+
let(:subject) { described_class.new { value } }
|
7
|
+
|
8
|
+
describe '#check?' do
|
9
|
+
context 'when block evaluates into true' do
|
10
|
+
it do
|
11
|
+
expect(subject.check?(controller)).to be_truthy
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when block evaluates into false' do
|
16
|
+
let(:value) { false }
|
17
|
+
it do
|
18
|
+
expect(subject.check?(controller)).to be_falsey
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -5,31 +5,35 @@ describe Tarquinn::Config do
|
|
5
5
|
|
6
6
|
describe '#add_redirection_rules' do
|
7
7
|
context 'when not passing a block' do
|
8
|
-
|
9
|
-
|
10
|
-
subject.add_redirection_rules(:methods)
|
11
|
-
end.to change { subject.methods }
|
8
|
+
it_behaves_like 'a method that adds a redirection rule', Tarquinn::Condition::MethodCaller do
|
9
|
+
let(:call_method) { subject.add_redirection_rules(:methods) }
|
12
10
|
end
|
11
|
+
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end.not_to change { subject.blocks }
|
13
|
+
context 'when passing only a block' do
|
14
|
+
it_behaves_like 'a method that adds a redirection rule', Tarquinn::Condition::ProcRunner do
|
15
|
+
let(:call_method) { subject.add_redirection_rules { true } }
|
18
16
|
end
|
19
17
|
end
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end.not_to change { subject.methods }
|
20
|
+
describe '#add_skip_rules' do
|
21
|
+
context 'when not passing a block' do
|
22
|
+
it_behaves_like 'a method that adds a skip rule', Tarquinn::Condition::MethodCaller do
|
23
|
+
let(:call_method) { subject.add_skip_rules(:methods) }
|
26
24
|
end
|
25
|
+
end
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end.to change { subject.blocks }
|
27
|
+
context 'when passing only a block' do
|
28
|
+
it_behaves_like 'a method that adds a skip rule', Tarquinn::Condition::ProcRunner do
|
29
|
+
let(:call_method) { subject.add_skip_rules { true } }
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
33
|
+
|
34
|
+
describe '#add_skip_action' do
|
35
|
+
it_behaves_like 'a method that adds a skip rule', Tarquinn::Condition::ActionChecker do
|
36
|
+
let(:call_method) { subject.add_skip_action(:methods) }
|
37
|
+
end
|
38
|
+
end
|
35
39
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tarquinn::Controller do
|
4
|
+
let(:controller) { Tarquinn::DummyController.new }
|
5
|
+
let(:subject) { described_class.new(controller) }
|
6
|
+
|
7
|
+
describe '#call' do
|
8
|
+
it 'redirects a method call to the controller' do
|
9
|
+
expect(controller).to receive(:redirect_to)
|
10
|
+
subject.call(:redirect_to)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#params' do
|
15
|
+
it 'returns the instance params call' do
|
16
|
+
expect(subject.params).to eq(action: 'show')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#has_method?' do
|
21
|
+
context 'when calling for a public method that exists' do
|
22
|
+
it do
|
23
|
+
expect(subject.has_method?(:parse_request)).to be_truthy
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when calling for a private method that exists' do
|
28
|
+
it do
|
29
|
+
expect(subject.has_method?(:redirection_path)).to be_truthy
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when calling for a non existing method' do
|
34
|
+
it do
|
35
|
+
expect(subject.has_method?(:non_existing)).to be_falsey
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -9,41 +9,8 @@ describe Tarquinn::Engine do
|
|
9
9
|
let(:config) { Tarquinn::Config.new(:redirect_path) }
|
10
10
|
let(:config2) { Tarquinn::Config.new(:redirect_path2) }
|
11
11
|
let(:configs) { { redirect_path: config, redirect_path2: config2 } }
|
12
|
-
let(:subject)
|
13
|
-
|
14
|
-
describe '#perform_redirect?' do
|
15
|
-
context 'when no redirection should be performed' do
|
16
|
-
before do
|
17
|
-
config.add_skip_rules { true }
|
18
|
-
config2.add_skip_rules { true }
|
19
|
-
end
|
20
|
-
|
21
|
-
it do
|
22
|
-
expect(subject.perform_redirect?).to be_falsey
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'when all redirection is required' do
|
27
|
-
before do
|
28
|
-
config.add_redirection_rules { true }
|
29
|
-
config2.add_redirection_rules { true }
|
30
|
-
end
|
31
|
-
|
32
|
-
it do
|
33
|
-
expect(subject.perform_redirect?).to be_truthy
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'when only one allow for redirection' do
|
38
|
-
before do
|
39
|
-
config.add_redirection_rules { true }
|
40
|
-
config2.add_skip_rules { true }
|
41
|
-
end
|
42
|
-
|
43
|
-
it do
|
44
|
-
expect(subject.perform_redirect?).to be_truthy
|
45
|
-
end
|
46
|
-
end
|
12
|
+
let(:subject) do
|
13
|
+
described_class.new configs, Tarquinn::Controller.new(controller)
|
47
14
|
end
|
48
15
|
|
49
16
|
describe '#perform_redirect' do
|
@@ -54,19 +21,19 @@ describe Tarquinn::Engine do
|
|
54
21
|
end
|
55
22
|
|
56
23
|
it 'redirects to the first redirection' do
|
57
|
-
expect(controller).not_to receive(:redirect_to)
|
24
|
+
expect(controller).not_to receive(:redirect_to)
|
58
25
|
subject.perform_redirect
|
59
26
|
end
|
60
27
|
end
|
61
28
|
|
62
|
-
context 'when all redirection
|
29
|
+
context 'when all redirection are required' do
|
63
30
|
before do
|
64
31
|
config.add_redirection_rules { true }
|
65
32
|
config2.add_redirection_rules { true }
|
66
33
|
end
|
67
34
|
|
68
35
|
it do
|
69
|
-
expect(controller).to receive(:redirect_to)
|
36
|
+
expect(controller).to receive(:redirect_to).with(redirection_path)
|
70
37
|
subject.perform_redirect
|
71
38
|
end
|
72
39
|
end
|
@@ -2,9 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Tarquinn::Handler do
|
4
4
|
let(:redirection_path) { '/path' }
|
5
|
-
let(:controller) {
|
6
|
-
let(:config) { Tarquinn::Config.new(:
|
7
|
-
let(:subject)
|
5
|
+
let(:controller) { Tarquinn::DummyController.new }
|
6
|
+
let(:config) { Tarquinn::Config.new(:redirection_path) }
|
7
|
+
let(:subject) do
|
8
|
+
described_class.new config, Tarquinn::Controller.new(controller)
|
9
|
+
end
|
8
10
|
|
9
11
|
describe '#perform_redirect?' do
|
10
12
|
context 'when rules allow for redirection' do
|
@@ -90,10 +92,19 @@ describe Tarquinn::Handler do
|
|
90
92
|
end
|
91
93
|
|
92
94
|
describe '#redirect' do
|
93
|
-
it do
|
95
|
+
it 'calls for redirection using controller method' do
|
94
96
|
expect(controller).to receive(:redirect_to).with(redirection_path)
|
95
97
|
subject.redirect
|
96
98
|
end
|
99
|
+
|
100
|
+
context 'when configured with a method that does not exist in the controller' do
|
101
|
+
let(:config) { Tarquinn::Config.new('/new_path') }
|
102
|
+
|
103
|
+
it 'calls for redirection using static path' do
|
104
|
+
expect(controller).to receive(:redirect_to).with('/new_path')
|
105
|
+
subject.redirect
|
106
|
+
end
|
107
|
+
end
|
97
108
|
end
|
98
109
|
end
|
99
110
|
end
|
data/spec/lib/tarquinn_spec.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
class Tarquinn::
|
1
|
+
class Tarquinn::DummyController
|
2
2
|
def self.before_action(_)
|
3
3
|
end
|
4
4
|
|
5
5
|
include Tarquinn
|
6
6
|
|
7
|
+
skip_redirection :redirection_path, :route_method
|
7
8
|
redirection_rule :redirection_path, :should_redirect?
|
8
9
|
skip_redirection_rule :redirection_path, :should_skip_redirect?
|
9
10
|
|
@@ -13,6 +14,18 @@ class Tarquinn::Controller
|
|
13
14
|
|
14
15
|
private
|
15
16
|
|
17
|
+
def params
|
18
|
+
{ action: 'show' }
|
19
|
+
end
|
20
|
+
|
21
|
+
def true
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def false
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
16
29
|
def redirection_path
|
17
30
|
'/path'
|
18
31
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
shared_examples 'a method that adds a redirection rule' do |expected_class|
|
2
|
+
it_behaves_like 'a method that adds a rule', :redirection, expected_class
|
3
|
+
end
|
4
|
+
|
5
|
+
shared_examples 'a method that adds a skip rule' do |expected_class|
|
6
|
+
it_behaves_like 'a method that adds a rule', :skip, expected_class
|
7
|
+
end
|
8
|
+
|
9
|
+
shared_examples 'a method that adds a rule' do |rule, expected_class|
|
10
|
+
let(:reverse_rule) { rule == :skip ? :redirection : :skip }
|
11
|
+
it do
|
12
|
+
expect do
|
13
|
+
call_method
|
14
|
+
end.to change { subject.public_send("#{rule}_blocks" ) }
|
15
|
+
end
|
16
|
+
|
17
|
+
it do
|
18
|
+
call_method
|
19
|
+
expect(subject.public_send("#{rule}_blocks" ).last).to be_a(expected_class)
|
20
|
+
end
|
21
|
+
|
22
|
+
it do
|
23
|
+
expect do
|
24
|
+
call_method
|
25
|
+
end.not_to change { subject.public_send("#{reverse_rule}_blocks" ) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tarquinn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DarthJee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -126,17 +126,27 @@ files:
|
|
126
126
|
- lib/tarquinn/builder.rb
|
127
127
|
- lib/tarquinn/class_methods.rb
|
128
128
|
- lib/tarquinn/concern.rb
|
129
|
+
- lib/tarquinn/condition.rb
|
130
|
+
- lib/tarquinn/condition/action_checker.rb
|
131
|
+
- lib/tarquinn/condition/method_caller.rb
|
132
|
+
- lib/tarquinn/condition/proc_runner.rb
|
129
133
|
- lib/tarquinn/config.rb
|
134
|
+
- lib/tarquinn/controller.rb
|
130
135
|
- lib/tarquinn/engine.rb
|
131
136
|
- lib/tarquinn/handler.rb
|
132
137
|
- lib/tarquinn/version.rb
|
133
138
|
- spec/lib/tarquinn/builder_spec.rb
|
139
|
+
- spec/lib/tarquinn/condition/action_checker_spec.rb
|
140
|
+
- spec/lib/tarquinn/condition/method_caller_spec.rb
|
141
|
+
- spec/lib/tarquinn/condition/proc_runner_spec.rb
|
134
142
|
- spec/lib/tarquinn/config_spec.rb
|
143
|
+
- spec/lib/tarquinn/controller_spec.rb
|
135
144
|
- spec/lib/tarquinn/engine_spec.rb
|
136
145
|
- spec/lib/tarquinn/handler_spec.rb
|
137
146
|
- spec/lib/tarquinn_spec.rb
|
138
147
|
- spec/spec_helper.rb
|
139
|
-
- spec/support/models/tarquinn/
|
148
|
+
- spec/support/models/tarquinn/dummy_controller.rb
|
149
|
+
- spec/support/shared_examples/config.rb
|
140
150
|
- tarquinn.gemspec
|
141
151
|
homepage: https://github.com/darthje/tarquinn
|
142
152
|
licenses: []
|