https://github.com/serradura/minitest-exploration
Project to explore the minitest gem
https://github.com/serradura/minitest-exploration
Last synced: about 2 months ago
JSON representation
Project to explore the minitest gem
- Host: GitHub
- URL: https://github.com/serradura/minitest-exploration
- Owner: serradura
- Created: 2016-01-02T15:40:00.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-06T01:29:46.000Z (almost 10 years ago)
- Last Synced: 2025-04-05T10:24:02.119Z (6 months ago)
- Language: Ruby
- Size: 42 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Project to explore the Minitest library
Based on posts:
- [Make Your Ruby Tests Cleaner with Minitest and Shoulda](http://www.sitepoint.com/minitest-shoulda)
- [Top 8 tools for Ruby on Rails code optimization and cleanup]( https://infinum.co/the-capsized-eight/articles/top-8-tools-for-ruby-on-rails-code-optimization-and-cleanup)## Installation
```sh
# Install ruby 2.3.0. e.g:
# rvm install 2.3.0# Enter in the project folder. e.g:
# cd ./minitest-explorationbundle install
# Execute autotest to verify the test coverage. e.g:
# autotest
# After execute autotest, open tmp/* to see all the code quality reports.
```## Usage
```ruby
# Load in the console (IRB)
# $ irb -I lib -r calculator# With a default OperationsHistory
calc = Calculator::EasyModel.newcalc.multiply 3,3
# => 9
calc.history.last
# => {:operation=>:multiply, :num1=>3, :num2=>3, :result=>9}# With a custom OperationsHistory
storage = Calculator::YAMLHistoryStorage.new
history = Calculator::OperationsHistory.new(storage)
scalc = Calculator::EasyModel.new(history)scalc.add 1, 1
# => 2
scalc.subtract 5, 2
# => 3
storage.data
# => [{:operation=>:add, :num1=>1, :num2=>1, :result=>2}, {:operation=>:subtract, :num1=>5, :num2=>2, :result=>3}]
scalc.history.last == storage.data.last
# => true# Verify the operations history file cache
require 'shell'
Shell.new.cat storage.filename
# => ---
# - :operation: :add
# :num1: 1
# :num2: 1
# :result: 2
# - :operation: :subtract
# :num1: 5
# :num2: 2
# :result: 3```
## How run the test suite
```sh
rake test
# Or
autotest
```## How run the benchmarks
```sh
rake bench
```## Code Quality tools
```sh
# https://github.com/colszowka/simplecov/blob/master/README.md
rake testopen tmp/coverage/index.html
# https://github.com/whitesmith/rubycritic/blob/master/README.md
rake rubycriticopen tmp/rubycritic/overview.html
# https://github.com/makaroni4/sandi_meter/blob/master/README.md
rake sandi_meteropen tmp/sandi_meter/index.html
```