spec
. It’s pretty similar to RSpec
.crystal
created this project structure for us.spec
folder? Yes, as you guess Crystal created this folder and the first spec for us. In Crystal a file is tested with corresponding _spec
file. Since we named our project as sample
it created a file named sample.cr
and the corresponding spec with spec/sample_spec.cr
.spec
and unit test
means the same so we can use them interchangeably.spec/sample_spec.cr
describe
, it
and should
.spec
s with the following purposes.describe
lets you group related specs.it
is used for defining a spec with the given title in between “”.should
is used for making assumptions about the spec.describe
d as Sample
and it
has one spec with the title of works
which makes the assumption that false should
equal true.crystal
command to the rescue.Sample
titled works
a.k.a Sample works
. Let’s make it pass(green).