Class: Helper
- Inherits:
-
Object
- Object
- Helper
- Defined in:
- lib/rails_helper.rb
Defined Under Namespace
Classes: Engine
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#block ⇒ Object
Returns the value of attribute block.
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#modules ⇒ Object
Returns the value of attribute modules.
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
- .current_controller ⇒ Object
- .dependencies ⇒ Object
-
.mock_controller ⇒ Object
see ./actionpack/test/controller/caching_test.rb OUCH!.
- .version ⇒ Object
Instance Method Summary collapse
- #_routes ⇒ Object
- #default_url_options ⇒ Object
-
#initialize(*args, &block) ⇒ Helper
constructor
A new instance of Helper.
- #session ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ Helper
Returns a new instance of Helper.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rails_helper.rb', line 20 def initialize(*args, &block) @options = args.. @args = args @block = block controllers, args = args.partition{|arg| ActionController::Base === arg} @controller = controllers.first || Helper.current_controller || Helper.mock_controller @modules = args @controller = controller @modules.push(nil) if @modules.empty? @modules.flatten.uniq.each do |mod| case mod when NilClass, :all, 'all' extend ::ActionView::Helpers when Module extend mod else raise ArgumentError, mod.class.name end end end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
15 16 17 |
# File 'lib/rails_helper.rb', line 15 def args @args end |
#block ⇒ Object
Returns the value of attribute block.
16 17 18 |
# File 'lib/rails_helper.rb', line 16 def block @block end |
#controller ⇒ Object
Returns the value of attribute controller.
17 18 19 |
# File 'lib/rails_helper.rb', line 17 def controller @controller end |
#modules ⇒ Object
Returns the value of attribute modules.
18 19 20 |
# File 'lib/rails_helper.rb', line 18 def modules @modules end |
#options ⇒ Object
Returns the value of attribute options.
14 15 16 |
# File 'lib/rails_helper.rb', line 14 def @options end |
Class Method Details
.current_controller ⇒ Object
61 62 63 |
# File 'lib/rails_helper.rb', line 61 def Helper.current_controller Current.controller end |
.dependencies ⇒ Object
6 7 8 9 10 11 |
# File 'lib/rails_helper.rb', line 6 def Helper.dependencies { 'rails_current' => [ 'rails_current', ' >= 1.0' ], 'rails_default_url_options' => [ 'rails_default_url_options', ' >= 1.0' ] } end |
.mock_controller ⇒ Object
see ./actionpack/test/controller/caching_test.rb OUCH!
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rails_helper.rb', line 46 def Helper.mock_controller require 'action_dispatch/testing/test_request.rb' require 'action_dispatch/testing/test_response.rb' store = ActiveSupport::Cache::MemoryStore.new controller = ApplicationController.new controller.perform_caching = true controller.cache_store = store request = ActionDispatch::TestRequest.new response = ActionDispatch::TestResponse.new controller.request = request controller.response = response controller.send(:default_url_options).merge!(DefaultUrlOptions) if defined?(DefaultUrlOptions) controller end |
.version ⇒ Object
2 3 4 |
# File 'lib/rails_helper.rb', line 2 def Helper.version '1.3.0' end |
Instance Method Details
#_routes ⇒ Object
65 66 67 |
# File 'lib/rails_helper.rb', line 65 def _routes Rails.application.routes end |
#default_url_options ⇒ Object
69 70 71 |
# File 'lib/rails_helper.rb', line 69 def defined?(DefaultUrlOptions) ? DefaultUrlOptions : {} end |
#session ⇒ Object
73 74 75 |
# File 'lib/rails_helper.rb', line 73 def session controller.session end |