ITeye博客

Ruby Rails

共 1 篇文章

RSpec 基本语法

describe和context describe和context方法用来组织相关的行为example。 使用一个字符串作为他们的参数,以及使用一个block来定义其上下文的范围。 写model的spec或者其他的unit test时,可以传一个Ruby类作为describe的第一个参数。Doing so also creates an implicit subject for the examples. describe Timesheet do …… end describe可以嵌套 一般使用: describe Timesheet do describe “#test” do ….. …

2012-04-18 23:53 · Ruby Rails