【发布时间】:2014-06-17 16:10:45
【问题描述】:
我最近从 RSpec 2.99 升级到了 RSpec 3。这将是我的规范之一:
require 'spec_helper'
describe User, :type => :model do
it "is invalid without a password" do
expect(FactoryGirl.build(:user, :password => nil).errors_on(:password).size).to eq(1)
end
end
end
我已经运行了 Transpec gem,它应该将我的大部分规范转换为 RSpec 3 语法。但是,我仍然收到此错误(以及其他一些错误):
Failure/Error: expect(FactoryGirl.build(:user, :password => nil).errors_on(:password).size).to eq(1)
NoMethodError:
undefined method `errors_on' for #<User:0x00000108beaba0>
我尝试以多种不同的方式重新编写测试,但错误不会消失。
有人可以帮忙吗?
【问题讨论】:
标签: ruby-on-rails rspec rspec-rails