我正在关注rails3tutorial,在进行一些测试时我不明白"it"关键字的含义如下:
require 'spec_helper'
describe UsersController do
render_views
describe "GET 'new'" do
it "should be successful" do
get 'new'
response.should be_success
end
it "should have the right title" do
get 'new'
response.should have_selector("title", :content => "Sign up")
end
end
end
Run Code Online (Sandbox Code Playgroud)
代码片段来自:http://ruby.railstutorial.org/chapters/filling-in-the-layout#top上市5.26
Rus*_*ell 18
我认为其他答案可以更明确,最初可能会让你感到困惑的是,it打破方法命名的大多数常用约定(例如,方法没有描述它的作用)以便制作代码作为一个整体读作一种句子.
因此,库不仅仅是创建一组测试,而是试图鼓励您通过类似于人类可读规范的方式来描述您的应用程序.