dcrec1-rspec-vraptor 0.2.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.
data/README.textile ADDED
@@ -0,0 +1,24 @@
1
+ h2. LICENSE:
2
+
3
+ (The MIT License)
4
+
5
+ Copyright (c) 2008 FIX
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ 'Software'), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,48 @@
1
+ require 'rubygems'
2
+ require 'rubygems/specification'
3
+ require 'rake'
4
+ require 'rake/gempackagetask'
5
+ require 'spec/rake/spectask'
6
+
7
+ GEM = "rspec-vraptor"
8
+ GEM_VERSION = "0.2.0"
9
+ SUMMARY = "RSpec for VRaptor Sexy URLs"
10
+ AUTHOR = "Diego Carrion"
11
+ EMAIL = "dc.rec1@gmail.com"
12
+ HOMEPAGE = "http://www.diegocarrion.com"
13
+
14
+ spec = Gem::Specification.new do |s|
15
+ s.name = GEM
16
+ s.version = GEM_VERSION
17
+ s.platform = Gem::Platform::RUBY
18
+ s.summary = SUMMARY
19
+ s.require_paths = ['lib']
20
+ s.files = FileList['lib/**/*.rb','[A-Z]*'].to_a
21
+
22
+ s.author = AUTHOR
23
+ s.email = EMAIL
24
+ s.homepage = HOMEPAGE
25
+
26
+ s.rubyforge_project = GEM # GitHub bug, gem isn't being build when this miss
27
+ end
28
+
29
+ Spec::Rake::SpecTask.new do |t|
30
+ t.spec_files = FileList['spec/**/*_spec.rb']
31
+ t.spec_opts = %w(-fs --color)
32
+ end
33
+
34
+ Rake::GemPackageTask.new(spec) do |pkg|
35
+ pkg.gem_spec = spec
36
+ end
37
+
38
+ desc "Install the gem locally"
39
+ task :install => [:package] do
40
+ sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
41
+ end
42
+
43
+ desc "Create a gemspec file"
44
+ task :make_spec do
45
+ File.open("#{GEM}.gemspec", "w") do |file|
46
+ file.puts spec.to_ruby
47
+ end
48
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec'
2
+ require 'rhyme'
3
+
4
+ import javax.servlet.http.HttpServletRequest
5
+ import javax.servlet.http.HttpServletResponse
6
+ import javax.servlet.http.HttpSession
7
+ import javax.servlet.FilterConfig
8
+ import javax.servlet.FilterChain
9
+ import javax.servlet.ServletContext
10
+ import javax.servlet.RequestDispatcher
11
+ import org.vraptor.VRaptorFilter
12
+ import java.util.HashSet
13
+ import java.util.Locale
14
+
15
+ require 'spec/vraptor/mocked_context'
16
+ require 'spec/vraptor/mocked_config'
17
+ require 'spec/vraptor/mocked_dispatcher'
18
+ require 'spec/vraptor/mocked_request'
19
+ require 'spec/vraptor/mocked_response'
20
+ require 'spec/vraptor/mocked_session'
@@ -0,0 +1,13 @@
1
+ class MockedFilterConfig
2
+ include FilterConfig
3
+
4
+ attr_accessor :context
5
+
6
+ def initialize(context)
7
+ @context = context
8
+ end
9
+
10
+ def getServletContext
11
+ @context
12
+ end
13
+ end
@@ -0,0 +1,66 @@
1
+ class MockedContext
2
+ include ServletContext
3
+ attr_accessor :attributes, :init_parameters, :basic_path
4
+
5
+ def initialize
6
+ @attributes = {}
7
+ @basic_path = java.io.File.new("").get_absolute_path
8
+ end
9
+
10
+ def get_init_parameter(x)
11
+ nil
12
+ end
13
+
14
+ def get_context(uri_path)
15
+ nil
16
+ end
17
+
18
+ def get_major_version
19
+ 0
20
+ end
21
+
22
+ def get_minor_version
23
+ 0
24
+ end
25
+
26
+ def get_mime_type(file)
27
+ nil
28
+ end
29
+
30
+ def get_resource_paths(path)
31
+ if path.eql? "/WEB-INF/classes/"
32
+ path = "target/classes/"
33
+ else
34
+ path = path.sub("/WEB-INF/classes/", "")
35
+ end
36
+ root_folder = java.io.File.new(java.io.File.new(@basic_path), path)
37
+ paths = HashSet.new
38
+ root_folder.list.each do |file_name|
39
+ if java.io.File.new(root_folder, file_name).is_directory
40
+ file_name = file_name + '/'
41
+ end
42
+ name = path + file_name
43
+ if name.include? ".class"
44
+ name = name.sub("target", "/WEB-INF")
45
+ end
46
+ paths.add(name)
47
+ end
48
+ paths
49
+ end
50
+
51
+ def get_real_path(x)
52
+ if !x.include? ".class"
53
+ java.io.File.new("").get_absolute_path + "/" + x
54
+ else
55
+ x
56
+ end
57
+ end
58
+
59
+ def set_attribute(x, y)
60
+ @attributes.merge!({x => y})
61
+ end
62
+
63
+ def get_attribute(x)
64
+ @attributes[x]
65
+ end
66
+ end
@@ -0,0 +1,6 @@
1
+ class MockedDispatcher
2
+ include RequestDispatcher
3
+
4
+ def forward(request, response)
5
+ end
6
+ end
@@ -0,0 +1,55 @@
1
+ class MockedRequest
2
+ include HttpServletRequest
3
+ attr_accessor :dispatcher, :session, :request_uri, :parameter_map, :headers, :attributes, :locale
4
+
5
+ def initialize(dispatcher, session, uri, map, injection, headers, locale)
6
+ @locale = locale
7
+ @attributes = injection
8
+ @headers = {'Host' => '72.14.205.100'}.merge! headers
9
+ @dispatcher, @session, @request_uri, @parameter_map = MockedDispatcher.new, session, uri, map
10
+ end
11
+
12
+ def get_request_dispatcher(x)
13
+ @dispatcher
14
+ end
15
+
16
+ def get_locale
17
+ @locale
18
+ end
19
+
20
+ def get_attribute(x)
21
+ @attributes[x]
22
+ end
23
+
24
+ def set_attribute(x, y)
25
+ @attributes.merge!({x => y})
26
+ end
27
+
28
+ def get_context_path
29
+ ""
30
+ end
31
+
32
+ def get_parameter_map
33
+ @parameter_map
34
+ end
35
+
36
+ def get_request_uri
37
+ @request_uri
38
+ end
39
+
40
+ def get_session
41
+ @session
42
+ end
43
+
44
+ def get_header(x)
45
+ @headers[x]
46
+ end
47
+
48
+ def set_header(x, y)
49
+ @headers.merge!({x => y})
50
+ end
51
+
52
+ def remove_attribute(x)
53
+ @attributes.delete x
54
+ end
55
+ end
@@ -0,0 +1,13 @@
1
+ class MockedResponse
2
+ include HttpServletResponse
3
+ attr_accessor :status
4
+
5
+ def initialize
6
+ @status = 200
7
+ end
8
+
9
+ def set_status(x)
10
+ @status = x
11
+ end
12
+
13
+ end
@@ -0,0 +1,26 @@
1
+ class MockedSession
2
+ include HttpSession
3
+ attr_accessor :attributes, :context, :id
4
+
5
+ def get_id
6
+ @id
7
+ end
8
+
9
+ def initialize(context, map, id)
10
+ @context = context
11
+ @attributes = map
12
+ @id = id
13
+ end
14
+
15
+ def set_attribute(x, y)
16
+ @attributes.merge!({x => y})
17
+ end
18
+
19
+ def get_attribute(x)
20
+ @attributes[x]
21
+ end
22
+
23
+ def get_servlet_context
24
+ @context
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ require 'environment'
2
+
3
+ def get(x, params_request = {}, params_session = {}, injection = {}, headers = {})
4
+ init
5
+ @response = MockedResponse.new
6
+ dispatcher = MockedRequestDispatcher.new
7
+ @session = MockedHttpSession.new($context, params_session, @session_id)
8
+ @request = MockedRequest.new(dispatcher, @session, x, Rhyme.translate(params_request), injection, headers, Locale.new('en', 'US'))
9
+
10
+ $filter.do_filter(@request, @response, $chain)
11
+ end
12
+
13
+ def init
14
+ if !$init
15
+ $context = MockedServletContext.new
16
+
17
+ $config = MockedFilterConfig.new($context)
18
+
19
+ $filter = VRaptorFilter.new
20
+ $filter.init($config)
21
+
22
+ $chain = mock(FilterChain)
23
+
24
+ $init = true
25
+ end
26
+
27
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dcrec1-rspec-vraptor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Diego Carrion
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-19 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: dc.rec1@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - lib/spec/vraptor.rb
26
+ - lib/spec/vraptor/mocked_session.rb
27
+ - lib/spec/vraptor/mocked_response.rb
28
+ - lib/spec/vraptor/mocked_config.rb
29
+ - lib/spec/vraptor/mocked_context.rb
30
+ - lib/spec/vraptor/mocked_request.rb
31
+ - lib/spec/vraptor/mocked_dispatcher.rb
32
+ - lib/environment.rb
33
+ - README.textile
34
+ - Rakefile
35
+ has_rdoc: false
36
+ homepage: http://www.diegocarrion.com
37
+ post_install_message:
38
+ rdoc_options: []
39
+
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ requirements: []
55
+
56
+ rubyforge_project: rspec-vraptor
57
+ rubygems_version: 1.2.0
58
+ signing_key:
59
+ specification_version: 2
60
+ summary: RSpec for VRaptor Sexy URLs
61
+ test_files: []
62
+