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 +51 -2
- data/Rakefile +1 -1
- data/lib/environment.rb +4 -0
- data/lib/spec/vraptor/mocked_http_response.rb +29 -0
- metadata +2 -2
data/README.textile
CHANGED
@@ -1,6 +1,55 @@
|
|
1
|
-
|
1
|
+
h2. INSTALLATION
|
2
2
|
|
3
|
-
|
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
data/lib/environment.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2009-01-30 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|