“它"是什么意思RSpec 中的关键字 do? [英] what does the "it" keyword do in RSpec?
本文介绍了“它"是什么意思RSpec 中的关键字 do?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在关注 rails3tutorial 并且在进行如下测试时我不明白it"关键字的含义:
I'm following the rails3tutorial and I don't understand the meaning of the "it" keyword when doing some testing as follows:
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
代码片段来自:http://ruby.railstutorial.org/chapters/filling-in-the-layout#top 清单 5.26
code fragment comes from: http://ruby.railstutorial.org/chapters/filling-in-the-layout#top listing 5.26
推荐答案
它不是 Ruby 关键字,而是 Rspec 框架的一部分.
It's not a Ruby keyword, it's part of the Rspec framework.
it
包含说明行为方面的代码示例定义.它由两个主要部分组成:描述字符串和代码示例,在 do/end 块中.
it
contains the code examples that illustrate the facet of behavior being
defined. It is comprised of two main parts: the description string and
the code example, in the do/end block.
这篇关于“它"是什么意思RSpec 中的关键字 do?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文