4 ms·
"Most testing libraries allow you to run a subset of tests based on their line number by running something like rspec spec/models/user_spec.rb:15." This sounds
by Hovertruck 13y ago
"Most testing libraries allow you to run a subset of tests based on their line number by running something like rspec spec/models/user_spec.rb:15."
This sounds... strange to me. When would this be an advantage over some sort of named test? e.g. `manage.py test Thing.validation_test`
- beaumartinez 13y ago> When would this be an advantage over some sort of named test? Never. "Line number" is very obscure and prone to breaking. "I just added a comment at the top of the file... Whoops! Broke all the tests." To quote the Zen Of Python—"explicit is better than implicit". The article is a bit old so I wonder if that is still a common Ruby practice (if it ever was).
- jlogsdon 13y agoRspec tests aren't simply named "Thing.validation_test", they are generally full sentence descriptions of what the functionality is (eg. "A User that belongs to a valid and paid account should allow creation of projects"). The only time I've ever run specific tests by line-number is when I am working on making that single test green. In cases like that the line-number hardly ever changes (if it does, its because I've modified before filters or added a new `let`). edit: for a bit more context: that entire string would not be typed in for the single test, it would be built from contexts. describe User do context "belongs to a valid and paid account" do it "should allow creation of projects" do end end end