monty-rspec-rails 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -2
- data/lib/monty-rspec-rails.rb +69 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -42,8 +42,8 @@ Some test examples:
|
|
42
42
|
authenticated_user
|
43
43
|
end
|
44
44
|
|
45
|
-
it '#
|
46
|
-
request_allowed?(:
|
45
|
+
it '#update is allowed' do
|
46
|
+
request_allowed?(:update, :post, :_method => 'put').should be_true
|
47
47
|
end
|
48
48
|
|
49
49
|
# And so on..
|
@@ -51,6 +51,16 @@ Some test examples:
|
|
51
51
|
end
|
52
52
|
|
53
53
|
|
54
|
+
There are two built-in examples to help you test standard CRUD controllers. To test
|
55
|
+
that ALL CRUD actions are accessible:
|
56
|
+
|
57
|
+
it_should_behave_like "full crud access"
|
58
|
+
|
59
|
+
To test that NO CRUD actions are accessible:
|
60
|
+
|
61
|
+
it_should_behave_like "no crud access"
|
62
|
+
|
63
|
+
|
54
64
|
|
55
65
|
Note on Patches/Pull Requests
|
56
66
|
=============
|
data/lib/monty-rspec-rails.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Monty
|
2
2
|
module RspecRails
|
3
3
|
def self.version
|
4
|
-
'0.
|
4
|
+
'0.3.0'
|
5
5
|
end
|
6
6
|
|
7
7
|
def public_user
|
@@ -22,6 +22,74 @@ module Monty
|
|
22
22
|
'rack.input' => StringIO.new(params.to_query)
|
23
23
|
delivery.allowed?
|
24
24
|
end
|
25
|
+
|
26
|
+
def self.included(parent)
|
27
|
+
|
28
|
+
parent.instance_eval <<-RUBY
|
29
|
+
shared_examples_for "full crud access" do
|
30
|
+
it '#index is allowed' do
|
31
|
+
request_allowed?(:index).should be_true
|
32
|
+
end
|
33
|
+
|
34
|
+
it '#show is allowed' do
|
35
|
+
request_allowed?(:show).should be_true
|
36
|
+
end
|
37
|
+
|
38
|
+
it '#new is allowed' do
|
39
|
+
request_allowed?(:new).should be_true
|
40
|
+
end
|
41
|
+
|
42
|
+
it '#create is allowed' do
|
43
|
+
request_allowed?(:create, :method => :post).should be_true
|
44
|
+
end
|
45
|
+
|
46
|
+
it "#edit is allowed" do
|
47
|
+
request_allowed?(:edit).should be_true
|
48
|
+
end
|
49
|
+
|
50
|
+
it '#update is allowed' do
|
51
|
+
request_allowed?(:update, :method => :put).should be_true
|
52
|
+
end
|
53
|
+
|
54
|
+
it '#destroy is allowed' do
|
55
|
+
request_allowed?(:destroy, :method => :delete).should be_true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
shared_examples_for "no crud access" do
|
62
|
+
it '#index is not allowed' do
|
63
|
+
request_allowed?(:index).should be_false
|
64
|
+
end
|
65
|
+
|
66
|
+
it '#show is not allowed' do
|
67
|
+
request_allowed?(:show).should be_false
|
68
|
+
end
|
69
|
+
|
70
|
+
it '#new is not allowed' do
|
71
|
+
request_allowed?(:new).should be_false
|
72
|
+
end
|
73
|
+
|
74
|
+
it '#create is not allowed' do
|
75
|
+
request_allowed?(:create, :method => :post).should be_false
|
76
|
+
end
|
77
|
+
|
78
|
+
it "#edit is not allowed" do
|
79
|
+
request_allowed?(:edit).should be_false
|
80
|
+
end
|
81
|
+
|
82
|
+
it '#update is not allowed' do
|
83
|
+
request_allowed?(:update, :method => :put).should be_false
|
84
|
+
end
|
85
|
+
|
86
|
+
it '#destroy is not allowed' do
|
87
|
+
request_allowed?(:destroy, :method => :delete).should be_false
|
88
|
+
end
|
89
|
+
end
|
90
|
+
RUBY
|
91
|
+
end
|
92
|
+
|
25
93
|
private
|
26
94
|
|
27
95
|
def login(session_stubs = {}, user_stubs = {})
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- stonean
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-20 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|