Relative Content

Tag Archive for ruby-on-railsrspec

RSpec expect(…).to receive(…).with(…) return error unexpected arguments with same variables

class Foo def fizz(user) puts user end end let(:user){create(:user)} it do expect(Foo).to receive(:fizz).with(user) end I run this test in RSpec of Rails app. Test fails with below result Foo received :fizz with unexpected arguments -[#<User id: 1, .. ,  created_at: “2024-09-18 10:39:41.403908004 +0900”, updated_at: “2024-09-18 10:39:41.579679422 +0900”] + [#<User id: 1, .. ,  created_at: “2024-09-18 […]

RSpec expect(…).to receive(…).with(…) return error unexpected arguments with same variables

class Foo def fizz(user) puts user end end let(:user){create(:user)} it do expect(Foo).to receive(:fizz).with(user) end I run this test in RSpec of Rails app. Test fails with below result Foo received :fizz with unexpected arguments -[#<User id: 1, .. ,  created_at: “2024-09-18 10:39:41.403908004 +0900”, updated_at: “2024-09-18 10:39:41.579679422 +0900”] + [#<User id: 1, .. ,  created_at: “2024-09-18 […]