Sha256: 5b1c6a45a4e97aa41f415e75193432b3f630fb41aed3db51132c03dcacd62bae

Contents?: true

Size: 1.29 KB

Versions: 18

Compression:

Stored size: 1.29 KB

Contents

require "webrat"

require "cgi"
gem "extlib"
require "extlib"
require "merb-core"

HashWithIndifferentAccess = Mash

module Webrat
  class MerbSession < Session #:nodoc:
    include Merb::Test::MakeRequest
    
    attr_accessor :response
    
    def get(url, data, headers = nil)
      do_request(url, data, headers, "GET")
    end
  
    def post(url, data, headers = nil)
      do_request(url, data, headers, "POST")
    end
  
    def put(url, data, headers = nil)
      do_request(url, data, headers, "PUT")
    end
  
    def delete(url, data, headers = nil)
      do_request(url, data, headers, "DELETE")
    end
    
    def response_body
      @response.body.to_s
    end
    
    def response_code
      @response.status
    end
    
    def do_request(url, data, headers, method)
      @response = request(url, 
        :params => (data && data.any?) ? data : nil, 
        :headers => headers,
        :method => method)
    end

  end
end

module Merb #:nodoc:
  module Test #:nodoc:
    module RequestHelper #:nodoc:
      def request(uri, env = {})
        @_webrat_session ||= Webrat::MerbSession.new
        @_webrat_session.response = @_webrat_session.request(uri, env)
      end
    end
  end
end

class Merb::Test::RspecStory #:nodoc:
  def browser
    @browser ||= Webrat::MerbSession.new
  end
end

Version data entries

18 entries across 18 versions & 4 rubygems

Version Path
adva-0.3.2 test/webrat/lib/webrat/merb_session.rb
adva-0.3.1 test/webrat/lib/webrat/merb_session.rb
adva-0.3.0 test/webrat/lib/webrat/merb_session.rb
adva-0.2.4 test/webrat/lib/webrat/merb_session.rb
adva-0.2.3 test/webrat/lib/webrat/merb_session.rb
adva-0.2.2 test/webrat/lib/webrat/merb_session.rb
adva-0.2.1 test/webrat/lib/webrat/merb_session.rb
adva-0.2.0 test/webrat/lib/webrat/merb_session.rb
adva-0.1.4 test/webrat/lib/webrat/merb_session.rb
adva-0.1.3 test/webrat/lib/webrat/merb_session.rb
adva-0.1.2 test/webrat/lib/webrat/merb_session.rb
adva-0.1.1 test/webrat/lib/webrat/merb_session.rb
adva-0.1.0 test/webrat/lib/webrat/merb_session.rb
adva-0.0.1 test/webrat/lib/webrat/merb_session.rb
aslakhellesoy-webrat-0.3.2.2 lib/webrat/merb.rb
brynary-webrat-0.4.0 lib/webrat/merb_session.rb
webrat-0.4.0 lib/webrat/merb_session.rb
webrat-0.4.1 lib/webrat/merb_session.rb