Ruby On Rails 面试系列七,一个面试练习题
现在面试流行让你写代码放到github上,这是其中一个要求:
Please create a todo-list application with the following capabilities:
-
Login and account creation
-
RSpec & Cucumber Tests
-
Bonus points for incorporating
-
Ajax(Drag & Drop to-do items)
-
CSS
-
Nice templates/layouts
-
Updating THIS README
- See: Tom Preston Werner
- See: Matt Parker
-
给你四个小时,能做多少算多少
我的解决方案附上
用jquery做了drag & drop
做了简单的templates
实现一部分的rspec测试
有一个简单todo的添加
附带我的没有过关的代码 。看样子人家要考察,设计模式,总之我的代码不符合要求。

We hope that this exercise will allow us to evaluate your skills as a developer. The qualities that we pay special attention to are:
- Simplicity/elegance of design
- Adherence to good software engineering principles
- Maintainability (clean, easy to understand code)
- Effective use of the standard library
- Use of unit tests

Write a Ruby program to first assemble a single set of records by parsing data from 3 different file formats and then display these records sorted in 3 different ways.
Details
The Data
A record consists of the following 5 fields: last name, first name, gender, date of birth and favorite color. You will be given 3 files, each containing records stored in a different format.
The pipe-delimited file lists each record as follows:
LastName | FirstName | MiddleInitial | Gender | FavoriteColor | DateOfBirth
The comma-delimited file looks like this:
LastName, FirstName, Gender, FavoriteColor, DateOfBirth
And lastly, the space-delimited file:
LastName FirstName MiddleInitial Gender DateOfBirth FavoriteColor
You may assume that the delimiters (commas, pipes and spaces) do not appear anywhere in the data values themselves. Write a Ruby program to read in records from these files and combine them into a single set of records.
Display Requirements
-
Create and display 3 different views of the recordset (see a sample here):
- Output 1 – sorted by gender (females before males) then by last name ascending.
- Output 2 – sorted by birth date, ascending.
- Output 3 – sorted by last name, descending.
-
Ensure that fields are displayed in the following order: last name, first name, gender, date of birth, favorite color.
-
Display dates in the format MM/DD/YYYY.
Packaging Requirements
- Please package the code in a zip or tar archive when you send it to us.
- Tell us which script or rake task to run in order to produce the desired output from your program.
- Specify what version of Ruby you’re using. You may use any official release of the CRuby interpreter.
- You may use the core and the standard library, but no gems, except Rake. If you do use Rake, specify the version.
Solutions as well as questions and comments should be sent to us at