1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RSpec has_attributesマッチャが使えない時

1
Last updated at Posted at 2018-10-02

オブジェクトの比較がしたい!
でも、Rspecのバージョンが古くてhas_attributesマッチャが使えない時


expect(User.new(:name => "hoge")).to have_attributes User.new(:name => "hoge")
---
undefined method `has_attributes?' 

attributesで比較すればできる。


expect(User.new(:name => "hoge").attributes).to eq User.new(:name => "hoge").attributes

長くなるが、古い環境だとしかたないので一旦これで解決。

参考

Ruby on Rails | ActiveRecord で オブジェクト同士を==で比較した場合、全属性が同値かどうかは検証しない

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?