首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >设计rspec测试

设计rspec测试
EN

Stack Overflow用户
提问于 2013-03-05 08:21:16
回答 1查看 285关注 0票数 0

为什么这个测试不能通过?我使用devise进行身份验证。

user.rb

代码语言:javascript
复制
  validates :username, presence: true, :length => { :minimum => 2 }

user_spec.rb

代码语言:javascript
复制
require 'spec_helper'

describe User do

  before do
    @user = User.new(username: "Example User", email: "user@example.com",
                     password: "foobar", password_confirmation: "foobar")
  end

  describe "name" do
    before { @user.username="test" }
    it { should be_valid }
  end

end
EN

回答 1

Stack Overflow用户

发布于 2013-03-05 12:13:07

您必须指定一个主题才能在RSpec中调用'it‘。例如,您可以添加

主题{ @user }

在你的“做之前”代码块之后。

以后,一定要复制错误消息,这样每个人都知道去哪里看!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15213634

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档