---
title: "Ruby面试系列二，说一个面试题"
author: "夜鸣猪"
date: "2011-09-29T23:51:12Z"
tags: []
categories: ["编程语言"]
slug: "ruby"
draft: false
lastmod: "2011-09-29T23:51:12Z"
id: 1183566
url: "https://hlee.iteye.com/blog/1183566"
---

这两天呢去一个小公司面试，创业公司做daily deals的要求见最下，公司有大概三十人左右，开发的有一小半，分两个开发组，每组一个QA。剩下的人都是市场或者销售。

面试的时候简单问了问经历，然后，要求pair programming，题目是实现一个BDD流程的ruby游戏。大概就是设计一个游戏，游戏比较简单，就是玩家输入颜色，形状，大小，如果依此输入符合规则那么游戏进行，如果不符合规则，就终止。

因为是ruby项目所以从RSPEC开始，我跟面试官讨论，看看能怎么测试，同时看怎么设计架构，应该有一个game类，可能还要分出来一个ruler类专门存储游戏规则，以便添加和修改规则。
所以，rspec可能会有
game ＝ Game.new(Ruler.new(1))
然后，按照规则用户要输入一个个颜色和大小和形状的参数
那么，我可能写测试
game.first_move = Move.new( 'blue', 'big', 'circle')
再就是验证规则
game.next_move.should_be = Move.new(Ruler.change)

当时，现场没有考虑Rspec的loop输入和规则的遍历问题
然后，我就建议先实现这个初步的测试，于是开始运行rspec，先是抱路径错误，看了看好像是helper没有include进来，然后，正常出现测试不通过错误，开始代码实现，代码实现部分反而比RSPEC设计部分要容易。面试时间有一个半小时吧，大体情况就这样。



> 
> Qualifications:
> Apache, Git, Memcached, MySQL
> Object-Oriented JavaScript, preferably with jQuery
> Experience in a fast-paced, Agile environment
> Bachelor's Degree or advanced degree in Computer Science, Engineering or related field or equivalent work experience
> Experience designing production-level applications
> Strong command of web standards and best practices
> Self-motivated individual willing to take ownership of key projects
> Excellent communication skills and leadership potential
> A passion for entrepreneurial endeavors
> The ability innovate when necessary to meet business requirements on a short timetable
> 
> Desired Skills:
> 
> NoSQL and MapReduce (e.g. MongoDb, Riak, HBase
> Continuous Integration, BDD, TDD
> HAML/SASS
> CoffeeScript
>