A quick presentation with some examples, about how RSpec should and can be used to write actual specs instead of just tests. It touches on differences between those two, and provides examples of useful RSpec DSL extensions.
Both framework are principal tools, more minimalistic, and thanks to that faster and closer with their DSL to pure ruby. The difference between specs and tests is actually quite big, with many not really knowing there is one.1 Spec, is a short form of specification and according to BDD it should enforce a way of thinking and constructing the code in a way which aims to describe what does the specified software does2 You can shorten this to call specs “tests that are written for humans”.
main point: RSpec is a tool much bigger than other testing frameworks we have in ruby. However many of its features, are not used by many of its users. In those cases, using it instead of alternatives (wspomiany MiniTest i TestBench) is a waste of resources. RSpec, despite some flaws, is the best ruby tool to build specs. It is not the best to build tests. Here i want to share some examples of how you can use its robust DSL to build better specs, that are actual specs, more than pure tests.
common pattern in RoR. In bare RSpec there is no special DSL for this pattern since its implementations differ… no DSL means we are testing it with pure ruby which makes it more of a test not spec We can build our own DSL in RSpec and end up with this spec and here: Matcher For Decorator is: (polish word for cat is pronounced similarly to polish word for code so its funny)
ready to go DSL, but also says it is supposed to be a base4, under the actual specifications of out software by extending what is given to us by default. We are supposed to extend it by the specification of our app. That is written by the creators of RSpec. So using RSpec remember to write specs, not just tests. If you want just tests, look for other tools Dogcat
for the whole software lifecycle by John Ferguson Smart 3. http://test-bench.software/ 4. Effective testing with RSpec - Myron Marston & Ian Dees (edycja 3, tłumaczenie własne)