https://github.com/hopsoft/grumpy_old_man
Asserts for RSpec
https://github.com/hopsoft/grumpy_old_man
Last synced: 6 months ago
JSON representation
Asserts for RSpec
- Host: GitHub
- URL: https://github.com/hopsoft/grumpy_old_man
- Owner: hopsoft
- Created: 2012-08-21T05:22:13.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2024-08-01T23:40:57.000Z (about 1 year ago)
- Last Synced: 2025-03-27T23:01:41.771Z (6 months ago)
- Language: Ruby
- Homepage:
- Size: 25.4 KB
- Stars: 13
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
# Grumpy Old Man
## Adding old school asserts to RSpec
GrumpyOldMan adds the following methods to RSpec without compromising any of RSpec's other features.
* `assert`
* `assert_equal`
* `assert_raise`
* `refute`> NOTE: If you're using [rspec-rails](https://github.com/rspec/rspec-rails), these methods are delegated to MiniTest and you don't need GrumpyOldMan.
Testing libraries exist to help you do the following.
1. Execute some code
1. Verify that it produced the expected outcomeOr more simply...
```ruby
assert true
```Unfortunately RSpec adds a lot of [unnecessary complexity](https://fs.blog/2018/01/complexity-bias/).
*Looking at you __expectations__ and __matchers__.*## Simplicity FTW
Consider the following example from the RSpec docs.
```ruby
expect(order.total).to eq(Money.new(5.55, :USD))
```Rewritten with GrumpyOldMan.
```ruby
assert order.total == Money.new(5.55, :USD)# or ...
assert_equal order.total, Money.new(5.55, :USD)
```Simple `asserts` encourage test code that resembles your application logic.
## Usage
```bash
bundle add grumpy_old_man
```Simply include GrumpyOldMan in your spec/test like so.
```ruby
require "grumpy_old_man"describe Thing do
include GrumpyOldManit "should be simple" do
assert true
assert_equal true, true
assert_raise(Exception) { raise }
refute false
end
end
```You may not agree, but I'm sticking with my old fashioned assert.
**Now get off my lawn!***If you like GrupyOldMan, check out [PryTest](https://github.com/hopsoft/pry-test) and discover just how serene testing can be.*