A
A
axelvagabund2016-03-23 04:29:13
Software testing
axelvagabund, 2016-03-23 04:29:13

What is the best way to BDD with Rspec?

Good morning. I am new to rails, and to the web in general, for about a year I have been doing this craft out of interest, having played enough with layout and jquery plugins, I decided to take on something more serious, so I began to study rails.
And... Everything is fine, there are more than enough manuals and tutorials, and the books are also wonderful. But for now I'm just stuck on testing, or rather bdd. I just can’t imagine how and what to write in tests, I read some books, watched presentations, but most often the functionality of this unit-test framework is described there, how and what to write, more tactful naming of describe / context / it blocks. I googled books, but found only 1 more or less to my liking, and even then it was 2010. So... The whole problem is that I just have no idea what and how to describe, it is obvious that in separate specs there are separate pieces of code (fuches, models, views, controllers), but how exactly, so that the test is complete, and not a couple of plain ones lines about an empty field, or a redirect if the user does not have rights / is not logged in.
Again, I apologize for such an amateurish question. But... Where can I find it, and... If you have your own thoughts / advice, I will be glad to hear them.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fahrenhe17, 2016-03-23
@axelvagabund

Everything that is written below is purely subjective and in no case should everything be perceived as pure and the only truth.
1. What to test?
The question is very tricky. Truth. Personally, I do more integration tests, i.e. testing what the user sees. This of course does not apply to API tests. But I also test more or less complex actions in the controller. I also don't test simple validations.
2. The name of the blocks.
I will say two words from myself and here is the resource. It's kind of mentioned somewhere in the beginning.
From myself - write the names in such a way that at the command

rspec --format documentation
you were given more or less coherent sentences.
ps Highly recommend the RSpec chapter from this book.
I'm sure I'm wrong about something and the rail gurus will correct me. I will only be glad. :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question