• Stars
    star
    40
  • Rank 658,546 (Top 14 %)
  • Language
    Crystal
  • License
    MIT License
  • Created almost 9 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PowerAssert provides the more powerful assertion to you.

power_assert.cr

docrystal.org

PowerAssert provides the more powerful assertion to you.

Usage

Very simple.

# spec/my_lib_spec.cr

describe MyLib do
  describe ".major_version" do
    it "should be equal 1" do
      assert MyLib.major_version == 1
    end
  end
end

If MyLib.major_version is 2:

F

Failures:

  1) MyLib .major_version should be equal 1
     Failure/Error: assert MyLib.major_version == 1

         MyLib.major_version == 1
         |                   |  |
         |                   |  1
         |                   false
         2

     # ./spec/my_lib_spec.cr:6

more examples in spec.

🎉 Happy testing! 🎉

Configure

  • global_indent : Int : A indent size of assertion messages.
  • sort_by : Symbol : Sort order of breakdowns. allowed: :default, :reverse, :left and :right.
  • expand_block : Bool : Show block's codes in the breakdown.

Example Outputs

Run crystal spec.

FFFFFF

Failures:

  1) PowerAssert Simple operators should be fail
     Failure/Error: assert 1 == 2

         1 == 2
         | |  |
         | false
         |    |
         |    2
         1

     # ./spec/power_assert_spec.cr:23

  2) PowerAssert Simple operators should be fail
     Failure/Error: assert 1 > 2

         1 > 2
         | | |
         | false
         |   |
         |   2
         1

     # ./spec/power_assert_spec.cr:27

  3) PowerAssert Method call should be fail
     Failure/Error: assert falsey == true

         falsey == true
         |      |  |
         |      false
         |         |
         |         true
         false

     # ./spec/power_assert_spec.cr:33

  4) PowerAssert Method call should be fail
     Failure/Error: assert example.falsey(one, two, three)

         example.falsey(one, two, three)
         |       |      |    |    |
         |       false  |    |    |
         |              1    |    |
         |                   2    |
         |                        3
         #<PowerAssert::Example:0x1087a6ee0>

     # ./spec/power_assert_spec.cr:42

  5) PowerAssert Method call should be fail
     Failure/Error: assert example.one == 2

         example.one == 2
         |       |   |  |
         |       |   false
         |       |      |
         |       |      2
         |       1
         #<PowerAssert::Example:0x1087a6e60>

     # ./spec/power_assert_spec.cr:48

  6) PowerAssert Method call should be fail
     Failure/Error: assert array.any? { |n| n == 0 }.nil?

         array.any? { ... }.nil?
         |     |            |
         |     |            false
         |     false
         [1, 2, 3]

     # ./spec/power_assert_spec.cr:54

Finished in 2.16 milliseconds
6 examples, 6 failures, 0 errors, 0 pending

Failed examples:

crystal spec ./spec/power_assert_spec.cr:22 # PowerAssert Simple operators should be fail
crystal spec ./spec/power_assert_spec.cr:26 # PowerAssert Simple operators should be fail
crystal spec ./spec/power_assert_spec.cr:32 # PowerAssert Method call should be fail
crystal spec ./spec/power_assert_spec.cr:36 # PowerAssert Method call should be fail
crystal spec ./spec/power_assert_spec.cr:45 # PowerAssert Method call should be fail
crystal spec ./spec/power_assert_spec.cr:51 # PowerAssert Method call should be fail
Program terminated abnormally with error code: 256

ToDo

  • Support a == b && c == d

License

Distributed under the MIT License. Please see LICENSE for details

Credits

  • Sho Kusano @rosylilly for the Crystal implementation
  • Takuto Wada @twada for the original JavaScript implementation. power_assert.cr is inspired by power-assert.

More Repositories

1

git-tasukete

gitで助けて欲しい時に
Shell
420
star
2

zengin_code

bank codes and branch codes for japanese
72
star
3

speed_gun

better web app profiler on Rails and Rack apps
Ruby
70
star
4

gondler

Bundler for golang
Ruby
69
star
5

react-jsx-renderer

A React component for Rendering JSX
TypeScript
47
star
6

git-hook

git-hook is very eazy git's hook management tool.
Shell
43
star
7

ruboty-slack_rtm

Slack(real time api) adapter for ruboty.
Ruby
40
star
8

gofu

on the fly image resizing application
Go
24
star
9

QueenCheck

like haskell's QuickCheck
Ruby
23
star
10

Nerine

Simple HTML5 Presentation Tools
JavaScript
21
star
11

git-set-mtime

set files mtime by latest commit time.
Go
21
star
12

dicer

useful DCI for Rails
Ruby
18
star
13

uninclude

Implement Module#uninclude and Object#unextend
Ruby
18
star
14

docrystal

docrystal.org hosts documentation for Crystal packages on GitHub
16
star
15

isucondar

"イスコンダル" is Benchmarker framework for ISUCON
15
star
16

sequel-cacheable

This plug-in caching mechanism to implement the Model of the Sequel
Ruby
15
star
17

phantom_dep

Detect your phantom dependencies(gems not in use).
Ruby
13
star
18

packer-provisioner-itamae

packer-provisioner-itamae is a Packer plugin for Itamae
Go
10
star
19

grape-msgpack

Message pack formatter for grape
Ruby
10
star
20

performania

Go
9
star
21

isucon11_prior

TypeScript
8
star
22

anix

Ruby
7
star
23

hpdf

a libharu binding for golang
Go
7
star
24

isucon11-prior

JavaScript
7
star
25

mount_doc

Railsアプリケーション組み込み型ドキュメント生成ツール
Ruby
7
star
26

reel

CLI Read-Eval-Execute-Loop tool
Ruby
6
star
27

middleman-webpack

CSS
6
star
28

github-keys

公開鍵おいしいです^q^
Ruby
5
star
29

jkiita

JavaScript
5
star
30

envdef

envdef provides methods of getting environment value with default value
Go
5
star
31

git_hook

git hooks management command line tool
Ruby
5
star
32

private-isu-benchmarker

Go
5
star
33

girimekra

Ruby
4
star
34

rosylilly.github.io

my web site
HTML
4
star
35

docker_registry

Ruby
4
star
36

desperado

集中することを……強いられているんだ!
Ruby
4
star
37

nicofive

コメントは特許侵害して訴えられたら怖いので多分実装しない似非プレーヤー
JavaScript
4
star
38

partitional

Provides partial model to your Rails
Ruby
4
star
39

Twail

tail -twitter
Ruby
3
star
40

pprocess

push to pushover
Go
3
star
41

bundler-add

Ruby
3
star
42

rails_with_websocket

Ruby
3
star
43

semver

Semantic Versioning module for Crystal
Crystal
3
star
44

git-advent-calendar-sample-special-happy

Qiita Ruby 開発環境 AdventCalendar のサンプル
Ruby
3
star
45

dotfiles

Shell
3
star
46

hiki-hatenagroup-auth

hiki hatena group auth plugin
Ruby
2
star
47

happy_birthday

Happy Birthday!
Ruby
2
star
48

active_strategy

Extract the business logic from the model
Ruby
2
star
49

Tatezora

青空文庫縦書きビューワー
JavaScript
2
star
50

rails_plugin_with_rspec

RailsのプラグインをRSpecでテストしながら作るときのひな形
Ruby
2
star
51

rock_motive

RockMotive provides DCI architecture to Rails
Ruby
2
star
52

at_exit

like ruby #at_exit
JavaScript
2
star
53

closure-linter

mirror https://developers.google.com/closure/utilities/
Python
2
star
54

spTouch

すまほでたっち
JavaScript
2
star
55

gondler-sample

Sample application for gondler
Go
2
star
56

mongoid-bcrypt-ruby

Useful BCrypt::Password for Mongoid
Ruby
2
star
57

mount_doc_sample

mount_docの使い方サンプル
Ruby
2
star
58

martini-graceful

graceful shutdown for martini
Go
2
star
59

choshi

Simple Decorator gem for Rails 3 and 4
Ruby
2
star
60

git_hook-rspec

git pre-commit hook. run all rspec.
Ruby
2
star
61

Poogie

like HTML5 Video API
ActionScript
1
star
62

isucon4-qualifier-rosylilly

Go
1
star
63

env

Go
1
star
64

den_den_markdown

WIP
Ruby
1
star
65

sakki

ゾイ!
Ruby
1
star
66

pio

io with progress
Go
1
star
67

gochat

Makefile
1
star
68

lper

some commands to replize
Ruby
1
star
69

EventEmitter.js

To grant all object event function
JavaScript
1
star
70

rails_test

test of rails
Ruby
1
star
71

lf

lf is a lightweight command-line LTSV processor
Ruby
1
star
72

sladon

Ruby
1
star
73

fi2zbu2z

fizzbuzz
C
1
star
74

epdisk

Shell
1
star
75

fake_env

A fake ENV for your tests.
Ruby
1
star
76

hatonizer

クルッポー
JavaScript
1
star
77

rainbows

copy of git://bogomips.org/rainbows.git
Ruby
1
star