`

Rails 笔试题

阅读更多
1.What is the notation used for denoting class variables in Ruby?

2.How is class methods defined in Ruby?

3. Whats the difference between symbol and string? 

4.What  it's print in screen?

def multiplier(n) 
  lambda {|data| data.collect{|x| x*n } }
end
doubler = multiplier(2)     # Get a lambda that knows how to double
puts doubler.call([1,2,3])  

5.What is the use of load and require in Ruby?
6.How do Dynamic define a Methods  and call a methods dynamically
7.Use  method_missing()  implement dynamic attribute
  class AccessorUtil
  def initialize
      #1 you could write your code here
  end

  def method_missing(name,*args)
      #2 you could write your code here
  end
end 
class StepUtil<AccessorUtil  end
test = StepUtil.new
test.send "a1=",9333
aaa= test.send "a1"
puts aaa

8.How do hook method work, please give example of hook method

9.What is the result after execution.
   "ruby123"[/\d+/] 
    "ruby123"[/([a-z]+)(\d+)/,1]  
"ruby123"[/([a-z]+)(\d+)/,2]


10. Point out the wrong code of Watir
require 'watir'

class WebPageUtil
  def initialize(ie)
    @dAttr=Hash.new
    @ie=ie
    @arr = ["text_field","checkbox","select_list","area","radio"]
    @filter = ["exampleid"]
  end

  def fill_form
    @dAttr.each do |name,value|
      if(!@filter.include?(name))
        @arr.each do |watir_method|
          begin
            el=@ie.send watir_method,:name,name
            if el.exist?
              case watir_method
              when "text_field"
                el.set value.to_s
              when "checkbox"
                if value.to_s =""
                  el.clear
                else
                  el.set
                end
              when "select_list"
                el.getAllContents
                el.set value.to_s
              when "area"
                el.append value.to_s
              when "radio"
                if value.to_s ==""
                  el.clear
                else
                  el.set
                end
              end
            end
          rescue
          end
        end
      end
    end

  end

  def method_missing(name,*args)
    key = name.to_s
    if name.to_s.include?("=")
      key = name.to_s.chop
      @dAttr[key]=args
    else
      if @dAttr.has_key?(name.to_s)
        return @dAttr[key].to_s
      else
        return nil
      end
    end
  end
end

ie = Watir::Browser.new
ie.goto "http://www.google.com"
dm= WebPageUtil.new(ie)
dm.q="goole"
dm.fill_form

11.Assumption you do the follow code refactor, what is your comment
require 'win32ole'
require 'lib/util/step_util'
require 'watir'
require 'lib/util/web_page_util'

class ExcelUtil
  def getAbsolutePath filename
    fso = WIN32OLE.new('Scripting.FileSystemObject')
    return fso.GetAbsolutePathName(filename)
  end
  def read_step (filename,sheet)
      filename = getAbsolutePath(filename)
      puts filename
      xl = WIN32OLE.new('Excel.Application')
      book = xl.Workbooks.Open(filename)
      record = []
      begin
        sheet = book.Sheets(sheet)
        head = StepUtil.new
        index = 0
        sheet.UsedRange.Rows(1).Cells.each do |cells|
           index+=1
           head.send "column#{index}=",cells.value
        end
          sheet.UsedRange.Rows.each do |row|
           if(row.Cells(1).value!="xpath")
              step = StepUtil.new
              index_1 = 0
             row.Cells.each do |cell|
               index_1+=1
               attr = head.send "column#{index_1}"
               
               step.send "#{attr}=",cell.value
             end
             
            record<<step  
           end
          end
      ensure
        book.Close
        xl.Quit
      end
      return record
    end
    
  def read_example (filename,sheet,ie)
        filename = getAbsolutePath(filename)
        puts filename
        xl = WIN32OLE.new('Excel.Application')
        book = xl.Workbooks.Open(filename)
        record = []
        begin
          sheet = book.Sheets(sheet)
          head = WebPageUtil.new(ie)
          index = 0
          sheet.UsedRange.Rows(1).Cells.each do |cells|
             index+=1
             head.send "column#{index}=",cells.value
          end
            sheet.UsedRange.Rows.each do |row|
             if(row.Cells(1).value!="exampleid")
                example = WebPageUtil.new(ie)
                index_1 = 0
               row.Cells.each do |cell|
                 index_1+=1
                 attr = head.send "column#{index_1}"
                 
                 example.send "#{attr}=",cell.value
               end
               
              record<<example 
             end
            end
        ensure
          book.Close
          xl.Quit
        end
        return record
      end
end


example = ExcelUtil.new
ie = Watir::Browser.new
ie.goto "http://www.google.com"
arr_ex = example.read_example("dos/example_group.xls","product_template",ie)
  arr_ex.each do |example|
    example.fill_form
    puts example       
    puts "_________________________"
  End

12.There is an error in the following code, please correct
require 'rubygems'
require 'active_record'  

ActiveRecord::Base.establish_connection(
    :adapter => "oci", 
    :username => "admin", 
    :password => "123456", 
    :host => "t31a.consys.prognet.com:1839/CTD09.real.com")

    
class Account < ActiveRecord::Base
  set_table_name "ADMIN_TOOL_ACCOUNT"
  set_primary_key "id"
  
end

temp = Account.find_by_user_name("Admin")
puts temp.id
puts temp.USER_NAME


13.Explain how Spec::Mocks work,and give an example
14. In ruby world, who hold object instance variable

A. Kernel  B. Class  C. Object  D. Module

15.Write down "my_method" Method lookup chain
class  A
end

class  B<A
   def my_method
          puts  "do something here"
       end
end

 obj = B.new
  obj.send("my_method")

2
0
分享到:
评论

相关推荐

    最新秋招freewheeljava笔试题.docx

    这篇文档是一份互联网公司的校招笔试题目,涵盖了多个技术领域。以下是这些题目涉及的知识点详解: ...以上就是这份笔试题中涉及的IT知识点,包括分布式系统、大数据、广告投放、机器学习、全栈开发、运维等多个方面。

    java中级工程师笔试题-other:其他

    java中级工程师笔试题精彩访谈 技术面试问题列表的精选列表。 如果你想贡献,请阅读 或 。 看看我或者打个招呼。 目录 编程语言/框架/平台 安卓 . AngularJS 主干JS C++ C C♯ 。网 Clojure 咖啡脚本 CSS 姜戈 ...

    高级java工程师笔试题-Javainterviewquestions:Java面试题

    高级java工程师笔试题目录 编程语言/框架/平台 安卓 AngularJS 角 主干JS C++ C C# 。网 Clojure CSS Cucumber 姜戈 码头工人 EmberJS 二郎 高朗 图Ql HTML 离子 IOS Java JavaScript jQuery 前端构建工具 ...

    高级java工程师笔试题-questions:查询

    高级java工程师笔试题精彩访谈 技术面试问题列表的精选列表。 如果你想贡献,请阅读 或 。 查看我的或 . 目录 编程语言/框架/平台 安卓 . AngularJS 主干JS C++ C C♯ 。网 Clojure CSS 姜戈 EmberJS 二郎 高朗 HTML...

    高级java工程师笔试题-InterviewPrep:面试准备链接

    高级java工程师笔试题面试准备 面试准备链接 目录 编程语言/框架/平台 安卓 . AngularJS 角 主干JS C++ C C# 。网 Clojure CSS Cucumber 姜戈 码头工人 EmberJS 二郎 高朗 图Ql HTML 离子 IOS Java JavaScript ...

    高级java工程师笔试题-Resources:资源

    高级java工程师笔试题精彩访谈 技术面试问题列表的精选列表。 如果你想贡献,请阅读 或 。 单击此按钮有助于为 Awesome 项目提供资金 目录 编程语言/框架/平台 安卓 . AngularJS 角 主干JS C++ C C# 。网 Clojure ...

    高级java工程师笔试题-New-Interview-question:新面试题

    高级java工程师笔试题精彩访谈 技术面试问题列表的精选列表。 如果你想贡献,请阅读 或 。 查看我的或 . 目录 编程语言/框架/平台 安卓 . AngularJS 角 主干JS C++ C C# 。网 Clojure CSS Cucumber 姜戈 码头工人 ...

    高级java工程师笔试题-eopen:打开

    高级java工程师笔试题技术面试技巧 技术面试问题列表的精选列表。 如果你想贡献,请阅读。 简历模板 为软件工程师准备的简历(Curriculum Vitae)模板。 . 是 CV(简历)的 LaTeX 模板。 目录 编程语言/框架/平台 C ...

    高级java工程师笔试题-Inteerview-Questions:面试问题

    高级java工程师笔试题精彩访谈 技术面试问题列表的精选列表。 如果你想贡献,请阅读 或 。 查看我的或 . 目录 编程语言/框架/平台 安卓 . AngularJS 主干JS C++ C C♯ 。网 Clojure CSS 姜戈 EmberJS 二郎 高朗 HTML...

    初级java笔试题-rigse:RITES项目的Rails活动生成器

    初级java笔试题CC Rails 门户活动创作、部署和报告系统 设置 先决条件 使用 git、ruby 或 jruby,以及 rubgems、wget Gems:capistrano、capistrano-ext、ruby-debug(奇怪的是,haml也是,部署时……) 待办事项:...

    java初级开发面试笔试题-ruby-job:Ruby工作

    java初级开发者面试笔试题Ruby工作 在招聘 Ruby on Rails 程序员时,一开始要知道面试中要问的正确问题对我来说是一个真正的挑战。 在 30 分钟或更短的时间内,如果不查看候选人之前编写的代码,很难全面了解候选人...

    高级java工程师笔试题-awesome:惊人的

    高级java工程师笔试题 精彩访谈 技术面试问题列表的精选列表。 如果你想贡献,请阅读 或 。 目录 编程语言/框架/平台 安卓 . AngularJS 角 主干JS C++ C C# 。网 Clojure CSS Cucumber 姜戈 码头工人 EmberJS 二郎 ...

    高级java工程师笔试题-irctc:铁道部

    高级java工程师笔试题精彩访谈 技术面试问题列表的精选列表。 如果你想贡献,请阅读 或 。 查看我的或 . 目录 编程语言/框架/平台 安卓 . AngularJS 主干JS C++ C C♯ 。网 Clojure CSS 姜戈 EmberJS 二郎 高朗 HTML...

    高级java工程师笔试题-InterviewCode:面试代码

    高级java工程师笔试题精彩访谈 技术面试问题列表的精选列表。 如果你想贡献,请阅读 或 。 查看我的或 . 目录 编程语言/框架/平台 安卓 . AngularJS 主干JS C++ C C♯ 。网 Clojure CSS 姜戈 EmberJS 二郎 高朗 HTML...

    java面试题笔试题-MaximAbramchuck-awesome-interview-questions:MaximAbramchuck真

    java面试题笔试题精彩访谈 技术面试问题列表的精选列表。 如果你想贡献,请阅读 或 。 查看我的或 . 目录 编程语言/框架/平台 安卓 . AngularJS 角 主干JS C++ C C♯ 。网 Clojure CSS Cucumber 姜戈 EmberJS 二郎 ...

    高级java工程师笔试题-awesome-interview-questions:真棒面试问题

    高级java工程师笔试题精彩访谈 技术面试问题列表的精选列表。 如果你想贡献,请阅读 或 。 查看我的或 . 目录 编程语言/框架/平台 安卓 . AngularJS 主干JS C++ C C♯ 。网 Clojure CSS 姜戈 EmberJS 二郎 高朗 HTML...

    高级java工程师笔试题-Interview-Questions:面试问题

    高级java工程师笔试题精彩访谈 技术面试问题列表的精选列表。 如果你想贡献,请阅读 或 。 单击此按钮有助于为 Awesome 项目提供资金 自豪地支持真棒项目 目录 编程语言/框架/平台 安卓 . AngularJS 角 主干JS C++ C...

    高级java工程师笔试题-interview-questions:面试问题

    高级java工程师笔试题精彩访谈 技术面试问题列表的精选列表。 如果你想贡献,请阅读 或 。 查看我的或 . 目录 编程语言/框架/平台 安卓 . AngularJS 角 主干JS C++ C C♯ 。网 Clojure CSS Cucumber 姜戈 EmberJS ...

    每日优鲜java笔试题-domtest:回购

    每日优鲜java笔试题Ruby书签 这是一个精选的基本 Ruby 和 Ruby on Rails 资源集合。 该项目旨在维护对初学者和高级 Web 开发人员同样有用的结构良好的参考。 ★ 代表编辑选择。 该列表不打算包括任何与 Ruby 编程...

Global site tag (gtag.js) - Google Analytics