ruby – “it”关键字在RSpec中做了什么?

前端之家收集整理的这篇文章主要介绍了ruby – “it”关键字在RSpec中做了什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在跟踪rails3tutorial,并且在做一些测试时,我不明白“it”关键字的含义如下:
  1. require 'spec_helper'
  2.  
  3. describe UsersController do
  4. render_views
  5.  
  6. describe "GET 'new'" do
  7. it "should be successful" do
  8. get 'new'
  9. response.should be_success
  10. end
  11.  
  12. it "should have the right title" do
  13. get 'new'
  14. response.should have_selector("title",:content => "Sign up")
  15. end
  16. end
  17. end

代码片段来自:http://ruby.railstutorial.org/chapters/filling-in-the-layout#top上市5.26

解决方法

它不是Ruby关键字,它是 Rspec framework的一部分.

它包含说明行为方面的代码示例定义.它由两个主要部分组成:描述字符串和代码示例,在do / end块中.

猜你在找的Ruby相关文章