dcrec1-rspec-vraptor 0.8 → 0.9
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 +1 -1
- data/lib/environment.rb +2 -0
- data/lib/spec/vraptor/mocked_cookie.rb +33 -0
- data/lib/spec/vraptor/mocked_http_request.rb +7 -2
- data/lib/spec/vraptor/mocked_http_response.rb +6 -1
- data/lib/spec/vraptor.rb +2 -2
- metadata +7 -6
data/Rakefile
CHANGED
data/lib/environment.rb
CHANGED
@@ -2,6 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'spec'
|
3
3
|
require 'rhyme'
|
4
4
|
|
5
|
+
import javax.servlet.http.Cookie
|
5
6
|
import javax.servlet.http.HttpServletRequest
|
6
7
|
import javax.servlet.http.HttpServletResponse
|
7
8
|
import javax.servlet.http.HttpSession
|
@@ -28,6 +29,7 @@ req_mocked 'http_request'
|
|
28
29
|
req_mocked 'http_response'
|
29
30
|
req_mocked 'request_dispatcher'
|
30
31
|
req_mocked 'servlet_context'
|
32
|
+
req_mocked 'cookie'
|
31
33
|
|
32
34
|
Spec::Runner.configure do |config|
|
33
35
|
config.include(VRaptorMatchers)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class MockedCookie < Cookie
|
2
|
+
attr_accessor :name, :value, :path, :max_age
|
3
|
+
|
4
|
+
def initialize(name, value)
|
5
|
+
@name = name
|
6
|
+
@value = value
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_name
|
10
|
+
@name
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_path
|
14
|
+
@path
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_value
|
18
|
+
@value
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_path path
|
22
|
+
@path = path
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_value value
|
26
|
+
@value = value
|
27
|
+
end
|
28
|
+
|
29
|
+
def set_max_age max_age
|
30
|
+
@max_age = max_age
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
class MockedHttpRequest
|
2
2
|
include HttpServletRequest
|
3
|
-
attr_accessor :dispatcher, :session, :request_uri, :parameter_map, :headers, :attributes, :locale, :context_path
|
3
|
+
attr_accessor :dispatcher, :session, :request_uri, :parameter_map, :headers, :attributes, :locale, :context_path, :cookies
|
4
4
|
|
5
|
-
def initialize(session, uri, map, injection, headers, locale)
|
5
|
+
def initialize(session, uri, map, injection, headers, locale, cookies)
|
6
6
|
@locale = locale
|
7
7
|
@attributes = injection
|
8
8
|
@headers = {'Host' => '72.14.205.100'}.merge! headers
|
9
9
|
@context_path = "/sso"
|
10
10
|
@session, @request_uri, @parameter_map = session, @context_path + uri, map
|
11
|
+
@cookies = cookies
|
11
12
|
end
|
12
13
|
|
13
14
|
def get_request_dispatcher(x)
|
@@ -71,4 +72,8 @@ class MockedHttpRequest
|
|
71
72
|
@dispatcher.nil?
|
72
73
|
end
|
73
74
|
|
75
|
+
def get_cookies
|
76
|
+
@cookies
|
77
|
+
end
|
78
|
+
|
74
79
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
class MockedHttpResponse
|
2
2
|
include HttpServletResponse
|
3
|
-
attr_accessor :status, :error, :target, :headers
|
3
|
+
attr_accessor :status, :error, :target, :headers, :cookies
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@status = 200
|
7
7
|
@headers = {}
|
8
|
+
@cookies = {}
|
8
9
|
end
|
9
10
|
|
10
11
|
def set_status(x)
|
@@ -27,4 +28,8 @@ class MockedHttpResponse
|
|
27
28
|
@headers[name] = value
|
28
29
|
end
|
29
30
|
|
31
|
+
def add_cookie(name, value)
|
32
|
+
@cookies[name] = value
|
33
|
+
end
|
34
|
+
|
30
35
|
end
|
data/lib/spec/vraptor.rb
CHANGED
@@ -2,10 +2,10 @@ require File.dirname(__FILE__) + '/../environment'
|
|
2
2
|
|
3
3
|
def get(x, map = {}) #params_request = {}, params_session = {}, injection = {}, headers = {})
|
4
4
|
init
|
5
|
-
params = {:request => {}, :session => {}, :inject => {}, :headers => {}}.merge map
|
5
|
+
params = {:request => {}, :session => {}, :inject => {}, :headers => {}, :cookies => {}}.merge map
|
6
6
|
@response = MockedHttpResponse.new
|
7
7
|
@session = MockedHttpSession.new($context, params[:session], @session_id)
|
8
|
-
@request = MockedHttpRequest.new(@session, x, Rhyme.translate(params[:request]), params[:inject], params[:headers], Locale.new('en', 'US'))
|
8
|
+
@request = MockedHttpRequest.new(@session, x, Rhyme.translate(params[:request]), params[:inject], params[:headers], Locale.new('en', 'US'), params[:cookies])
|
9
9
|
|
10
10
|
$filter.do_filter(@request, @response, $chain)
|
11
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.9"
|
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-03-
|
12
|
+
date: 2009-03-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -23,13 +23,14 @@ extra_rdoc_files: []
|
|
23
23
|
|
24
24
|
files:
|
25
25
|
- lib/spec/vraptor.rb
|
26
|
+
- lib/spec/vraptor/mocked_cookie.rb
|
27
|
+
- lib/spec/vraptor/matchers.rb
|
28
|
+
- lib/spec/vraptor/mocked_servlet_context.rb
|
26
29
|
- lib/spec/vraptor/mocked_http_response.rb
|
27
|
-
- lib/spec/vraptor/mocked_config.rb
|
28
|
-
- lib/spec/vraptor/mocked_http_session.rb
|
29
30
|
- lib/spec/vraptor/mocked_request_dispatcher.rb
|
30
|
-
- lib/spec/vraptor/
|
31
|
+
- lib/spec/vraptor/mocked_http_session.rb
|
32
|
+
- lib/spec/vraptor/mocked_config.rb
|
31
33
|
- lib/spec/vraptor/mocked_http_request.rb
|
32
|
-
- lib/spec/vraptor/matchers.rb
|
33
34
|
- lib/environment.rb
|
34
35
|
- README.textile
|
35
36
|
- Rakefile
|