Module: Webrat::Methods

Defined in:
lib/webrat/core/methods.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.delegate_to_session(*meths) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/webrat/core/methods.rb', line 4

def self.delegate_to_session(*meths)
  meths.each do |meth|
    self.class_eval(<<-RUBY, __FILE__, __LINE__)
      def #{meth}(*args, &blk)
        webrat_session.#{meth}(*args, &blk)
      end
    RUBY
  end
end

Instance Method Details

#responseObject

Temporary hack to work with Rails 3



27
28
29
30
31
32
33
# File 'lib/webrat/core/methods.rb', line 27

def response
  if Webrat.configuration.mode == :rack
    webrat_session.response
  else
    super
  end
end

#webratObject



14
15
16
# File 'lib/webrat/core/methods.rb', line 14

def webrat
  webrat_session
end

#webrat_sessionObject



18
19
20
21
22
23
24
# File 'lib/webrat/core/methods.rb', line 18

def webrat_session
  @_webrat_session ||= begin
    session = Webrat.session_class.new
    session.adapter = Webrat.adapter_class.new(self) if session.respond_to?(:adapter=)
    session
  end
end