Module: FocusedController::TestHelper
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActionDispatch::Assertions::ResponseAssertions
- Defined in:
- lib/focused_controller/test_helper.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
156
157
158
159
160
161
162
|
# File 'lib/focused_controller/test_helper.rb', line 156
def method_missing(method_name, *args, &block)
if respond_to?(method_name)
send(method_name, *args, &block)
else
super
end
end
|
Instance Method Details
#assert_redirected_to(location, message = nil) ⇒ Object
138
139
140
141
|
# File 'lib/focused_controller/test_helper.rb', line 138
def assert_redirected_to(location, message = nil)
controller super
end
|
#assert_response(type, message = nil) ⇒ Object
133
134
135
136
|
# File 'lib/focused_controller/test_helper.rb', line 133
def assert_response(type, message = nil)
controller super
end
|
#assert_template(template, message = nil) ⇒ Object
129
130
131
|
# File 'lib/focused_controller/test_helper.rb', line 129
def assert_template(template, message = nil)
assert_equal template.to_s, controller._render_options[:template], message
end
|
#controller ⇒ Object
99
100
101
102
103
104
105
106
107
|
# File 'lib/focused_controller/test_helper.rb', line 99
def controller
@controller ||= begin
controller = self.class.controller_class.new
controller.singleton_class.send :include, TestHooks
controller.request = request
controller.response = response
controller
end
end
|
#cookies ⇒ Object
125
126
127
|
# File 'lib/focused_controller/test_helper.rb', line 125
def cookies
request.cookie_jar
end
|
#flash ⇒ Object
121
122
123
|
# File 'lib/focused_controller/test_helper.rb', line 121
def flash
controller.flash
end
|
#optimize_routes_generation? ⇒ Boolean
180
181
182
|
# File 'lib/focused_controller/test_helper.rb', line 180
def optimize_routes_generation?(*)
false
end
|
#request ⇒ Object
109
110
111
|
# File 'lib/focused_controller/test_helper.rb', line 109
def request
@request ||= TestRequest.new
end
|
#respond_to?(*args) ⇒ Boolean
147
148
149
150
151
152
153
154
|
# File 'lib/focused_controller/test_helper.rb', line 147
def respond_to?(*args)
unless defined?(@_routes_included) && @_routes_included
self.class.include_routes
@_routes_included = true
end
super
end
|
#response ⇒ Object
113
114
115
|
# File 'lib/focused_controller/test_helper.rb', line 113
def response
@response ||= TestResponse.new
end
|
#session ⇒ Object
117
118
119
|
# File 'lib/focused_controller/test_helper.rb', line 117
def session
controller.session
end
|
#stub_url(*names) ⇒ Object
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'lib/focused_controller/test_helper.rb', line 164
def stub_url(*names)
[self, controller].each do |host|
host.singleton_class.class_eval do
names.each do |name|
define_method("#{name}_url") do |*args|
StubbedURL.new("#{name}_url", args)
end
define_method("#{name}_path") do |*args|
StubbedURL.new("#{name}_path", args)
end
end
end
end
end
|
#url_for(*args) ⇒ Object
143
144
145
|
# File 'lib/focused_controller/test_helper.rb', line 143
def url_for(*args)
controller.url_for(*args)
end
|