module Ki class MockReq attr_accessor :request_method attr_accessor :params def get? request_method == 'GET' end def post? request_method == 'POST' end def put? request_method == 'PUT' end def delete? request_method == 'DELETE' end def search? request_method == 'SEARCH' end end class ReqFactory def self.new sym, params={} case sym when :get, :post, :put, :delete, :head, :search mr = MockReq.new mr.request_method = sym.to_s.upcase mr.params = params return mr when :post_homer mr = MockReq.new mr.request_method = 'POST' mr.params = { 'user' => 'homer' } return mr else raise "not a valid factory" end end end end