dcrec1-rspec-vraptor 0.3.3 → 0.4

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 CHANGED
@@ -1,6 +1,55 @@
1
- Before runnint specs:
1
+ h2. INSTALLATION
2
2
 
3
- [code]export CLASSPATH=inc/servlet-api-2.5.jar:inc/vraptor-2.6.3.jar:inc/log4j-1.2.12.jar[/code]
3
+ <pre><code>jruby -S gem install dcrec1-rspec-vraptor -s http://gems.github.com</code></pre>
4
+
5
+ h2. USAGE
6
+
7
+ Include the rspec and rspec-vraptor gems in your specs:
8
+
9
+ <pre><code>require 'spec'
10
+ require 'spec/vraptor'</code></pre>
11
+
12
+ Now write code like this:
13
+
14
+ <pre><code>import com.mouseoverstudio.myapp.controller.UserController
15
+ import com.mouseoverstudio.myapp.model.User
16
+
17
+ describe UserController do
18
+
19
+ context "show service" do
20
+
21
+ before :all do
22
+ get "/user/xpto", :request => {'param1' => 'value1'},
23
+ :session => {'login' => 'dcrec1'},
24
+ :inject => {'user' => User.new("Bruce")},
25
+ :headers => {'Host' => '20.85.17.10'}
26
+ end
27
+
28
+ it "should send to the view an attribute 'logged' as true" do
29
+ @request.attributes['logged'].should be_true
30
+ end
31
+
32
+ it "should return 203 as http response code" do
33
+ @response.status.should eql(203)
34
+ end
35
+
36
+ it "should save param1 in session" do
37
+ @session.attributes['param1'].should eql('value')
38
+ end
39
+
40
+ end
41
+
42
+ end</code></pre>
43
+
44
+ h2. SPECING:
45
+
46
+ Before running specs:
47
+
48
+ <pre><code>export CLASSPATH=inc/servlet-api-2.5.jar:inc/vraptor-2.6.3.jar:inc/log4j-1.2.12.jar</code></pre>
49
+
50
+ Then to spec:
51
+
52
+ <pre><code>jruby -S rake spec</code></pre>
4
53
 
5
54
  h2. LICENSE:
6
55
 
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
5
5
  require 'spec/rake/spectask'
6
6
 
7
7
  GEM = "rspec-vraptor"
8
- GEM_VERSION = "0.3.5"
8
+ GEM_VERSION = "0.4"
9
9
  SUMMARY = "RSpec for VRaptor Sexy URLs"
10
10
  AUTHOR = "Diego Carrion"
11
11
  EMAIL = "dc.rec1@gmail.com"
data/lib/environment.rb CHANGED
@@ -23,3 +23,7 @@ req 'http_request'
23
23
  req 'http_response'
24
24
  req 'request_dispatcher'
25
25
  req 'servlet_context'
26
+
27
+ Spec::Runner.configure do |config|
28
+ config.include(VRaptorMatchers)
29
+ end
@@ -14,4 +14,33 @@ class MockedHttpResponse
14
14
  @error = {:code => code, :msg => msg}
15
15
  end
16
16
 
17
+ def send_redirect(path)
18
+ @redirect = path
19
+ end
20
+
21
+ def destination
22
+ @redirect
23
+ end
24
+
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
17
46
  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.3.3
4
+ version: "0.4"
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-01-22 00:00:00 -08:00
12
+ date: 2009-01-30 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15