加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 22:13:14 所属栏目:百科 来源:网络整理
导读:我正在跟踪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 "sh
我正在跟踪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

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

解决方法

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读