dcrec1-rspec-vraptor 0.4 → 0.5
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.
data/Rakefile
CHANGED
data/lib/environment.rb
CHANGED
@@ -14,15 +14,20 @@ import java.util.HashSet
|
|
14
14
|
import java.util.Locale
|
15
15
|
|
16
16
|
def req(x)
|
17
|
-
require File.dirname(__FILE__) + "/spec/vraptor
|
17
|
+
require File.dirname(__FILE__) + "/spec/vraptor/#{x}"
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
req
|
22
|
-
|
23
|
-
|
24
|
-
req '
|
25
|
-
|
20
|
+
def req_mocked(x)
|
21
|
+
req "mocked_#{x}"
|
22
|
+
end
|
23
|
+
|
24
|
+
req 'matchers'
|
25
|
+
req_mocked 'config'
|
26
|
+
req_mocked 'http_session'
|
27
|
+
req_mocked 'http_request'
|
28
|
+
req_mocked 'http_response'
|
29
|
+
req_mocked 'request_dispatcher'
|
30
|
+
req_mocked 'servlet_context'
|
26
31
|
|
27
32
|
Spec::Runner.configure do |config|
|
28
33
|
config.include(VRaptorMatchers)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module VRaptorMatchers
|
2
|
+
class RedirectTo
|
3
|
+
def initialize(path)
|
4
|
+
@path = path
|
5
|
+
end
|
6
|
+
|
7
|
+
def matches?(target)
|
8
|
+
@target = target
|
9
|
+
@target.destination.eql? @path
|
10
|
+
end
|
11
|
+
|
12
|
+
def failure_message
|
13
|
+
"expected response to redirect to #{@target.destination}, is redirecting to #{@path}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def redirect_to(expected)
|
18
|
+
RedirectTo.new(expected)
|
19
|
+
end
|
20
|
+
|
21
|
+
class Render
|
22
|
+
def initialize(target)
|
23
|
+
@target = "/#{target}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def matches?(request)
|
27
|
+
@dispatcher = request.dispatcher
|
28
|
+
@dispatcher.target.eql? @target
|
29
|
+
end
|
30
|
+
|
31
|
+
def failure_message
|
32
|
+
"expected response to redirect to #{@dispatcher.target}, is redirecting to #{@target}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def redirect_to(expected)
|
37
|
+
RedirectTo.new(expected)
|
38
|
+
end
|
39
|
+
|
40
|
+
def render(expected)
|
41
|
+
Render.new(expected)
|
42
|
+
end
|
43
|
+
end
|
@@ -2,14 +2,15 @@ class MockedHttpRequest
|
|
2
2
|
include HttpServletRequest
|
3
3
|
attr_accessor :dispatcher, :session, :request_uri, :parameter_map, :headers, :attributes, :locale
|
4
4
|
|
5
|
-
def initialize(
|
5
|
+
def initialize(session, uri, map, injection, headers, locale)
|
6
6
|
@locale = locale
|
7
7
|
@attributes = injection
|
8
8
|
@headers = {'Host' => '72.14.205.100'}.merge! headers
|
9
|
-
@
|
9
|
+
@session, @request_uri, @parameter_map = session, uri, map
|
10
10
|
end
|
11
11
|
|
12
12
|
def get_request_dispatcher(x)
|
13
|
+
@dispatcher = MockedRequestDispatcher.new(x)
|
13
14
|
@dispatcher
|
14
15
|
end
|
15
16
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class MockedHttpResponse
|
2
2
|
include HttpServletResponse
|
3
|
-
attr_accessor :status, :error
|
3
|
+
attr_accessor :status, :error, :target
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@status = 200
|
@@ -15,32 +15,11 @@ class MockedHttpResponse
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def send_redirect(path)
|
18
|
-
@
|
18
|
+
@target = path
|
19
19
|
end
|
20
20
|
|
21
21
|
def destination
|
22
|
-
@
|
22
|
+
@target
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
26
|
-
|
27
|
-
module VRaptorMatchers
|
28
|
-
class RedirectTo
|
29
|
-
def initialize(path)
|
30
|
-
@path = path
|
31
|
-
end
|
32
|
-
|
33
|
-
def matches?(target)
|
34
|
-
@target = target
|
35
|
-
@target.destination.eql? @path
|
36
|
-
end
|
37
|
-
|
38
|
-
def failure_message
|
39
|
-
"expected response to redirect to #{@target.destination}, is redirecting to #{@path}"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def redirect_to(expected)
|
44
|
-
RedirectTo.new(expected)
|
45
|
-
end
|
46
|
-
end
|
data/lib/spec/vraptor.rb
CHANGED
@@ -4,9 +4,8 @@ def get(x, map = {}) #params_request = {}, params_session = {}, injection = {},
|
|
4
4
|
init
|
5
5
|
params = {:request => {}, :session => {}, :inject => {}, :headers => {}}.merge map
|
6
6
|
@response = MockedHttpResponse.new
|
7
|
-
dispatcher = MockedRequestDispatcher.new
|
8
7
|
@session = MockedHttpSession.new($context, params[:session], @session_id)
|
9
|
-
@request = MockedHttpRequest.new(
|
8
|
+
@request = MockedHttpRequest.new(@session, x, Rhyme.translate(params[:request]), params[:inject], params[:headers], Locale.new('en', 'US'))
|
10
9
|
|
11
10
|
$filter.do_filter(@request, @response, $chain)
|
12
11
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dcrec1-rspec-vraptor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.5"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diego Carrion
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-02-04 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -29,6 +29,7 @@ files:
|
|
29
29
|
- lib/spec/vraptor/mocked_request_dispatcher.rb
|
30
30
|
- lib/spec/vraptor/mocked_servlet_context.rb
|
31
31
|
- lib/spec/vraptor/mocked_http_request.rb
|
32
|
+
- lib/spec/vraptor/matchers.rb
|
32
33
|
- lib/environment.rb
|
33
34
|
- README.textile
|
34
35
|
- Rakefile
|