iro*_*and 1 rspec ruby-on-rails
我想测试一个User模型属性的存在.所以我这样写.
describe "Authentications" do
it "sign up with twitter" do
visit new_user_session_path
expect { click_link "Sign up with Twitter"}.to change(User, :count).by(1)
end
describe "new user" do
let(:new_user) { User.last }
it "should have slug" do
#new_user its(:slug) { should eq("foo") }
new_user.slug should exist
end
end
end
Run Code Online (Sandbox Code Playgroud)
第一次测试通过,但第二次测试失败,出现这样的错误.
1) Authentications new user should have slug
Failure/Error: new_user.slug should exist
NoMethodError:
"new user" does not respond to either #exist? or #exists?
# ./spec/features/autentication_spec.rb:13:in `block (3 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)
我想我的方法是错误的.我该怎么用?
毕竟我不仅要检查它的存在,还要检查它的价值.但它也失败了.
| 归档时间: |
|
| 查看次数: |
1186 次 |
| 最近记录: |