specstar-controllers 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/specstar/controllers.rb +25 -14
- metadata +2 -2
data/lib/specstar/controllers.rb
CHANGED
@@ -25,7 +25,19 @@ module Specstar
|
|
25
25
|
}
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def has_before_filter_for_action?(controller, filter, action=nil)
|
29
|
+
controller._process_action_callbacks.any? { |callback|
|
30
|
+
callback.chain.any? { |chain|
|
31
|
+
if action
|
32
|
+
chain.kind == :before && chain.filter.to_s == filter.to_s && chain.per_key[:if].any? { |item| item.include? "action_name == '#{action}'" }
|
33
|
+
else
|
34
|
+
chain.kind == :before && chain.filter.to_s == filter.to_s
|
35
|
+
end
|
36
|
+
}
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def has_skip_before_filter?(controller, filter, actions=[])
|
29
41
|
if actions.present?
|
30
42
|
actions.all? { |action| has_skip_before_filter_for_action?(controller, filter, action) }
|
31
43
|
else
|
@@ -33,22 +45,21 @@ module Specstar
|
|
33
45
|
end
|
34
46
|
end
|
35
47
|
|
36
|
-
def has_before_filter?(controller, filter,
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
}.size > 0
|
48
|
+
def has_before_filter?(controller, filter, actions=[])
|
49
|
+
if actions.present?
|
50
|
+
actions.all? { |action| has_before_filter_for_action?(controller, filter, action) }
|
51
|
+
else
|
52
|
+
has_before_filter_for_action?(controller, filter)
|
53
|
+
end
|
43
54
|
end
|
44
55
|
|
45
56
|
RSpec::Matchers.define :have_skip_before_filter do |filter|
|
46
57
|
chain :only do |actions|
|
47
|
-
@
|
58
|
+
@actions = *actions
|
48
59
|
end
|
49
60
|
|
50
61
|
match do |controller|
|
51
|
-
has_skip_before_filter?(controller, filter, @
|
62
|
+
has_skip_before_filter?(controller, filter, @actions)
|
52
63
|
end
|
53
64
|
|
54
65
|
failure_message_for_should do |controller|
|
@@ -65,12 +76,12 @@ module Specstar
|
|
65
76
|
end
|
66
77
|
|
67
78
|
RSpec::Matchers.define :have_before_filter do |filter|
|
68
|
-
chain :only do |
|
69
|
-
@
|
79
|
+
chain :only do |actions|
|
80
|
+
@actions = *actions
|
70
81
|
end
|
71
82
|
|
72
83
|
match do |controller|
|
73
|
-
has_before_filter?(controller, filter, @
|
84
|
+
has_before_filter?(controller, filter, @actions)
|
74
85
|
end
|
75
86
|
|
76
87
|
failure_message_for_should do |controller|
|
@@ -87,4 +98,4 @@ module Specstar
|
|
87
98
|
end
|
88
99
|
end
|
89
100
|
end
|
90
|
-
end
|
101
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specstar-controllers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-24 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email: sujoyg@gmail.com
|