Mock = Minitest::Mock.new mock.expect(:method, args, return) mock. with has imprecise keyword arg matching in Ruby 3.like RSpec, can also call expects on any object, not just a Mock/ Stub. This would add the option: inputs :input1, :input2, :input3 raiseerrorwith :value1, value2. It wasn’t immediately obvious how to translate rspec-expectations and rspec-mocks to Minitest, so here’s my attempt at a cheatsheet: RSpecĮxpect().to receive().with().and_return() Currently, raiseerrorwith can receive a message or an Exception object. My first exposure to a testing library in Ruby and Rails was RSpec, but I’m now using Minitest. If the function is expected to raise an exception (for example, when testing input validation), this can be tested by chaining the andraiseerror method on. Wasabigeek Mocking in RSpec VS Minitest: A Cheatsheet
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |