Module: Rspec::Rails23::Helpers

Defined in:
lib/rspec/rails23/helpers.rb

Defined Under Namespace

Modules: InstanceMethods Classes: HelperController

Class Method Summary collapse

Class Method Details

.extended(kls) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/rspec/rails23/helpers.rb', line 68

def self.extended(kls)
  kls.send(:include, InstanceMethods)

  kls.send(:attr_reader, :request, :response)

  ActionView::Base.included_modules.reverse.each do |mod|
    kls.send(:include, mod) if mod.parents.include?(ActionView::Helpers)
  end

  kls.before do
    @controller = ::Rspec::Rails23::Helpers::HelperController.new
    @request = ActionController::TestRequest.new
    @response = ActionController::TestResponse.new
    @response.session = @request.session
    @controller.request = @request
    @flash = ActionController::Flash::FlashHash.new
    @response.session['flash'] = @flash

    ActionView::Helpers::AssetTagHelper::reset_javascript_include_default

    helper.session = @response.session
    helper.request = @request
    helper.flash = @flash
    helper.params = params
    helper.controller = @controller
  end

end