spicycode-micronaut-rails 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml
CHANGED
@@ -20,74 +20,67 @@ module Micronaut
|
|
20
20
|
|
21
21
|
end
|
22
22
|
|
23
|
+
module TemplateIsolationExtensions
|
24
|
+
def file_exists?(ignore); true; end
|
25
|
+
|
26
|
+
def render_file(*args)
|
27
|
+
@first_render ||= args[0] unless args[0] =~ /^layouts/
|
28
|
+
end
|
29
|
+
|
30
|
+
def render(*args)
|
31
|
+
return super if Hash === args.last && args.last[:inline]
|
32
|
+
record_render(args[0])
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def record_render(opts)
|
38
|
+
@_rendered ||= {}
|
39
|
+
(@_rendered[:template] ||= opts[:file]) if opts[:file]
|
40
|
+
(@_rendered[:partials][opts[:partial]] += 1) if opts[:partial]
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
|
23
46
|
module RenderOverrides
|
24
47
|
|
25
48
|
def render_views!
|
26
49
|
@render_views = true
|
27
50
|
end
|
28
51
|
|
29
|
-
def
|
52
|
+
def rendering_views?
|
30
53
|
@render_views
|
31
54
|
end
|
32
55
|
|
33
|
-
def render(options=nil, &block)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
if @template.respond_to?(:finder)
|
38
|
-
(class << @template.finder; self; end).class_eval do
|
39
|
-
define_method :file_exists? do; true; end
|
40
|
-
end
|
41
|
-
else
|
42
|
-
(class << @template; self; end).class_eval do
|
43
|
-
define_method :file_exists? do; true; end
|
44
|
-
end
|
56
|
+
def render(options=nil, extra_options={}, &block)
|
57
|
+
unless block_given?
|
58
|
+
unless rendering_views?
|
59
|
+
@template.extend TemplateIsolationExtensions
|
45
60
|
end
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
@first_render ||= args[0] unless args[0] =~ /^layouts/
|
50
|
-
@_first_render ||= args[0] unless args[0] =~ /^layouts/
|
51
|
-
end
|
52
|
-
|
53
|
-
define_method :_pick_template do |*args|
|
54
|
-
@_first_render ||= args[0] unless args[0] =~ /^layouts/
|
55
|
-
PickedTemplate.new
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
super(options, &block)
|
61
|
+
end
|
62
|
+
|
63
|
+
super
|
63
64
|
end
|
64
65
|
|
65
66
|
end
|
66
67
|
|
67
|
-
# Returned by _pick_template when running controller examples in isolation mode.
|
68
|
-
class PickedTemplate
|
69
|
-
# Do nothing when running controller examples in isolation mode.
|
70
|
-
def render_template(*ignore_args); end
|
71
|
-
# Do nothing when running controller examples in isolation mode.
|
72
|
-
def render_partial(*ignore_args); end
|
73
|
-
end
|
74
|
-
|
75
68
|
def self.extended(extended_behaviour)
|
76
69
|
extended_behaviour.send :include, ::ActionController::TestProcess, InstanceMethods, ::Micronaut::Rails::Matchers::Controllers
|
77
70
|
extended_behaviour.describes.send :include, RenderOverrides, ::ActionController::TestCase::RaiseActionExceptions
|
78
71
|
|
79
72
|
extended_behaviour.before do
|
80
|
-
@
|
81
|
-
@controller.request = @request = ::ActionController::TestRequest.new
|
73
|
+
@request = ::ActionController::TestRequest.new
|
82
74
|
@response = ::ActionController::TestResponse.new
|
83
|
-
@
|
84
|
-
|
75
|
+
@controller ||= self.class.describes.new
|
76
|
+
|
77
|
+
@controller.request = @request
|
85
78
|
@controller.params = {}
|
86
|
-
@controller.send(:initialize_current_url)
|
79
|
+
@controller.send(:initialize_current_url)
|
87
80
|
end
|
88
81
|
|
89
82
|
end
|
90
83
|
|
91
84
|
end
|
92
85
|
end
|
93
|
-
end
|
86
|
+
end
|
@@ -10,11 +10,24 @@ module Micronaut
|
|
10
10
|
@expected = expected
|
11
11
|
end
|
12
12
|
|
13
|
-
def matches?(
|
13
|
+
def matches?(response_or_controller)
|
14
|
+
response = response_or_controller.respond_to?(:response) ?
|
15
|
+
response_or_controller.response :
|
16
|
+
response_or_controller
|
17
|
+
|
14
18
|
if response.respond_to?(:rendered_file)
|
15
19
|
@actual = response.rendered_file
|
16
|
-
elsif response.respond_to?(:
|
17
|
-
|
20
|
+
elsif response.respond_to?(:rendered)
|
21
|
+
case template = response.rendered[:template]
|
22
|
+
when nil
|
23
|
+
unless response.rendered[:partials].empty?
|
24
|
+
@actual = path_and_file(response.rendered[:partials].keys.first).join("/_")
|
25
|
+
end
|
26
|
+
when ActionView::Template
|
27
|
+
@actual = template.path
|
28
|
+
when String
|
29
|
+
@actual = template
|
30
|
+
end
|
18
31
|
else
|
19
32
|
@actual = response.rendered_template.to_s
|
20
33
|
end
|
@@ -100,4 +113,4 @@ module Micronaut
|
|
100
113
|
end
|
101
114
|
end
|
102
115
|
end
|
103
|
-
end
|
116
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spicycode-micronaut-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Humphries
|
@@ -9,11 +9,12 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-04-05 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: actionpack
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
@@ -23,6 +24,7 @@ dependencies:
|
|
23
24
|
version:
|
24
25
|
- !ruby/object:Gem::Dependency
|
25
26
|
name: spicycode-micronaut
|
27
|
+
type: :runtime
|
26
28
|
version_requirement:
|
27
29
|
version_requirements: !ruby/object:Gem::Requirement
|
28
30
|
requirements:
|
@@ -36,8 +38,9 @@ executables: []
|
|
36
38
|
|
37
39
|
extensions: []
|
38
40
|
|
39
|
-
extra_rdoc_files:
|
40
|
-
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README
|
43
|
+
- LICENSE
|
41
44
|
files:
|
42
45
|
- LICENSE
|
43
46
|
- Rakefile
|