specstar-controllers 0.0.9 → 0.1.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.
- checksums.yaml +7 -0
- data/lib/specstar/controllers.rb +52 -56
- metadata +9 -13
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 70b81e777192e989185b7bb53cc71aedfca646c9
|
4
|
+
data.tar.gz: 9cb56320474181becd9df8ef1e612cedad35710f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b8c30a1f0a01c42fcf42b219b5d7bcfb660a1c7a530082ba297640a552e7ad55c89c06fe824ce8bea9d825ed5ba9b3032a268038f6e3a61ab8fb3c405d852abd
|
7
|
+
data.tar.gz: b21bf28b036416851752c7ee40a60e99215478f4ed707ab0aa615cd901daa327cb7bc52a5d56ef1cac99ddaed89fa2df7abba31fad50f66040b7a8fddfada7b7
|
data/lib/specstar/controllers.rb
CHANGED
@@ -5,64 +5,60 @@ module Specstar
|
|
5
5
|
module Matchers
|
6
6
|
RSpec::Matchers.define :have_layout do |expected|
|
7
7
|
match do |controller|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
if expected
|
9
|
+
expected.to_s == controller.class.instance_variable_get("@_layout")
|
10
|
+
else
|
11
|
+
controller.class.instance_variable_get("@_layout")
|
12
|
+
end
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
15
|
+
failure_message_for_should do |controller|
|
16
|
+
if expected
|
17
|
+
"Expected #{controller.class.name} to have layout '#{expected}'."
|
18
|
+
else
|
19
|
+
"Expected #{controller.class.name} to have layout."
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
failure_message_for_should_not do |controller|
|
24
|
+
if expected
|
25
|
+
"Expected #{controller.class.name} not to have layout '#{expected}'."
|
26
|
+
else
|
27
|
+
"Expected #{controller.class.name} not to have layout."
|
28
|
+
end
|
29
|
+
end
|
30
30
|
end
|
31
31
|
|
32
32
|
def has_skip_before_filter_for_action?(controller, filter, action)
|
33
33
|
controller._process_action_callbacks.any? { |callback|
|
34
|
-
callback.
|
35
|
-
chain.kind == :before && chain.filter.to_s == filter.to_s && chain.per_key[:unless].any? { |item| item.include? "action_name == '#{action}'" }
|
36
|
-
}
|
34
|
+
callback.kind == :before && callback.filter.to_s == filter.to_s && callback.per_key[:unless].any? { |item| item.include? "action_name == '#{action}'" }
|
37
35
|
}
|
38
36
|
end
|
39
37
|
|
40
38
|
def has_before_filter_for_action?(controller, filter, action=nil)
|
41
39
|
controller._process_action_callbacks.any? { |callback|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
48
|
-
}
|
40
|
+
if action
|
41
|
+
callback.kind == :before && callback.filter.to_s == filter.to_s && callback.per_key[:if].any? { |item| item.include? "action_name == '#{action}'" }
|
42
|
+
else
|
43
|
+
callback.kind == :before && callback.filter.to_s == filter.to_s
|
44
|
+
end
|
49
45
|
}
|
50
46
|
end
|
51
47
|
|
52
48
|
def has_skip_before_filter?(controller, filter, actions=[])
|
53
49
|
if actions.present?
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
50
|
+
actions.all? { |action| has_skip_before_filter_for_action?(controller, filter, action) }
|
51
|
+
else
|
52
|
+
!has_before_filter?(controller, filter)
|
53
|
+
end
|
58
54
|
end
|
59
55
|
|
60
56
|
def has_before_filter?(controller, filter, actions=[])
|
61
57
|
if actions.present?
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
58
|
+
actions.all? { |action| has_before_filter_for_action?(controller, filter, action) }
|
59
|
+
else
|
60
|
+
has_before_filter_for_action?(controller, filter)
|
61
|
+
end
|
66
62
|
end
|
67
63
|
|
68
64
|
RSpec::Matchers.define :have_skip_before_filter do |filter|
|
@@ -74,17 +70,17 @@ module Specstar
|
|
74
70
|
has_skip_before_filter?(controller, filter, @actions)
|
75
71
|
end
|
76
72
|
|
77
|
-
|
78
|
-
|
79
|
-
|
73
|
+
failure_message_for_should do |controller|
|
74
|
+
"Expected #{controller.class.name} to have a skip before filter '#{filter}'."
|
75
|
+
end
|
80
76
|
|
81
|
-
|
82
|
-
|
83
|
-
|
77
|
+
failure_message_for_should_not do |controller|
|
78
|
+
"Expected #{controller.class.name} not to have a skip before filter '#{filter}'."
|
79
|
+
end
|
84
80
|
|
85
|
-
|
86
|
-
|
87
|
-
|
81
|
+
description do
|
82
|
+
"have a skip before filter '#{filter}'."
|
83
|
+
end
|
88
84
|
end
|
89
85
|
|
90
86
|
RSpec::Matchers.define :have_before_filter do |filter|
|
@@ -96,17 +92,17 @@ module Specstar
|
|
96
92
|
has_before_filter?(controller, filter, @actions)
|
97
93
|
end
|
98
94
|
|
99
|
-
|
100
|
-
|
101
|
-
|
95
|
+
failure_message_for_should do |controller|
|
96
|
+
"Expected #{controller.class.name} to have a before filter '#{filter}'."
|
97
|
+
end
|
102
98
|
|
103
|
-
|
104
|
-
|
105
|
-
|
99
|
+
failure_message_for_should_not do |controller|
|
100
|
+
"Expected #{controller.class.name} not to have a before filter '#{filter}'."
|
101
|
+
end
|
106
102
|
|
107
|
-
|
108
|
-
|
109
|
-
|
103
|
+
description do
|
104
|
+
"have a before filter '#{filter}'."
|
105
|
+
end
|
110
106
|
end
|
111
107
|
end
|
112
108
|
end
|
metadata
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specstar-controllers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sujoy Gupta
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec-core
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
description:
|
@@ -36,26 +33,25 @@ files:
|
|
36
33
|
- lib/specstar/controllers.rb
|
37
34
|
homepage: http://github.com/sujoyg/specstar-controllers
|
38
35
|
licenses: []
|
36
|
+
metadata: {}
|
39
37
|
post_install_message:
|
40
38
|
rdoc_options: []
|
41
39
|
require_paths:
|
42
40
|
- lib
|
43
41
|
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
-
none: false
|
45
42
|
requirements:
|
46
|
-
- -
|
43
|
+
- - '>='
|
47
44
|
- !ruby/object:Gem::Version
|
48
45
|
version: '0'
|
49
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
47
|
requirements:
|
52
|
-
- -
|
48
|
+
- - '>='
|
53
49
|
- !ruby/object:Gem::Version
|
54
50
|
version: '0'
|
55
51
|
requirements: []
|
56
52
|
rubyforge_project:
|
57
|
-
rubygems_version: 1.
|
53
|
+
rubygems_version: 2.1.4
|
58
54
|
signing_key:
|
59
|
-
specification_version:
|
55
|
+
specification_version: 4
|
60
56
|
summary: RSpec helpers for controllers.
|
61
57
|
test_files: []
|