angus 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/angus/request_handler.rb +7 -2
- data/lib/angus/version.rb +1 -1
- data/spec/angus/request_handler_spec.rb +29 -0
- metadata +2 -2
@@ -4,7 +4,6 @@ require_relative 'response'
|
|
4
4
|
require_relative 'responses'
|
5
5
|
require_relative 'middleware/exception_handler'
|
6
6
|
require_relative 'exceptions'
|
7
|
-
MiddlewareNotFound
|
8
7
|
|
9
8
|
module Angus
|
10
9
|
class RequestHandler
|
@@ -90,5 +89,11 @@ module Angus
|
|
90
89
|
@middleware.insert(index + 1, [middleware, args, block])
|
91
90
|
end
|
92
91
|
|
92
|
+
def disuse(middleware)
|
93
|
+
index = @middleware.map(&:first).index(middleware) or raise MiddlewareNotFound.new(middleware)
|
94
|
+
|
95
|
+
@middleware.delete_at(index)
|
96
|
+
end
|
97
|
+
|
93
98
|
end
|
94
|
-
end
|
99
|
+
end
|
data/lib/angus/version.rb
CHANGED
@@ -97,4 +97,33 @@ describe Angus::RequestHandler, { :work_dir => work_dir } do
|
|
97
97
|
|
98
98
|
end
|
99
99
|
|
100
|
+
describe '#disuse' do
|
101
|
+
|
102
|
+
let(:other_middleware) { Struct.new(:app) }
|
103
|
+
|
104
|
+
it 'removes the given class from the middleware' do
|
105
|
+
handler.disuse(Angus::Middleware::ExceptionHandler)
|
106
|
+
|
107
|
+
handler.middleware.map(&:first).should_not include(Angus::Middleware::ExceptionHandler)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'removes only given class from the middleware' do
|
111
|
+
handler.use(other_middleware)
|
112
|
+
|
113
|
+
handler.disuse(Angus::Middleware::ExceptionHandler)
|
114
|
+
|
115
|
+
handler.middleware.map(&:first).should_not include(Angus::Middleware::ExceptionHandler)
|
116
|
+
handler.middleware.map(&:first).should include(other_middleware)
|
117
|
+
end
|
118
|
+
|
119
|
+
context 'when the given class is not present in the middleware' do
|
120
|
+
it 'raises an MiddlewareNotFound error' do
|
121
|
+
expect {
|
122
|
+
handler.disuse(Angus::Middleware)
|
123
|
+
}.to raise_error(MiddlewareNotFound)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
100
129
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: angus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-12-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: thor
|